library(psych) # for the describe() command
library(expss) # for the cross_cases() command
Basic Statistics HW
Load Libraries
Load Data
<- read.csv(file="Data/mydata.csv", header=T)
d names(d)
[1] "gender" "age" "swb" "support" "socmeduse" "stress"
Univariate Plots: Histograms & Tables
table(d$gender)
f m nb
1586 544 31
table(d$age)
1 between 18 and 25 2 between 26 and 35 3 between 36 and 45 4 over 45
1989 116 38 18
hist(d$swb)
hist(d$support)
hist(d$socmeduse)
hist(d$stress)
Univariate Normality
Check skew and kurtosis. Cutoffs are -2 to +2; if skew or kurtosis are higher or lower than these values, I need to mention it in my writeup!!!!!
describe(d)
vars n mean sd median trimmed mad min max range skew
gender* 1 2161 1.28 0.48 1.00 1.21 0.00 1.0 3.0 2.0 1.36
age* 2 2161 1.11 0.43 1.00 1.00 0.00 1.0 4.0 3.0 4.41
swb 3 2161 4.44 1.33 4.50 4.49 1.48 1.0 7.0 6.0 -0.35
support 4 2161 5.53 1.13 5.75 5.65 0.99 0.0 7.0 7.0 -1.08
socmeduse 5 2161 34.25 8.59 35.00 34.51 7.41 11.0 55.0 44.0 -0.31
stress 6 2161 3.07 0.60 3.10 3.07 0.59 1.3 4.6 3.3 -0.02
kurtosis se
gender* 0.71 0.01
age* 21.07 0.01
swb -0.49 0.03
support 1.31 0.02
socmeduse 0.20 0.18
stress -0.15 0.01
Bivariate Plots
Crosstabs
cross_cases(d, gender, age)
age | ||||
---|---|---|---|---|
1 between 18 and 25 | 2 between 26 and 35 | 3 between 36 and 45 | 4 over 45 | |
gender | ||||
f | 1476 | 70 | 28 | 12 |
m | 483 | 46 | 9 | 6 |
nb | 30 | 1 | ||
#Total cases | 1989 | 116 | 38 | 18 |
Scatterplots
plot(d$swb, d$support,
main="Scatterplot of Satisfaction with Life Scale and Support",
xlab = "Satisfaction with Life",
ylab = "Support")
plot(d$swb, d$socmeduse,
main="Scatterplot of Satisfaction with Life Scale and Social Media Use",
xlab = "Satisfaction with Life",
ylab = "Social Media Use")
plot(d$swb, d$stress,
main="Scatterplot of Satisfaction with Life Scale and Stress",
xlab = "Satisfaction with Life",
ylab = "Stress")
plot(d$support, d$socmeduse,
main="Scatterplot of Support and Social Media Use",
xlab = "Support",
ylab = "Social Media Use")
plot(d$support, d$stress,
main="Scatterplot of Support and Stress",
xlab = "Support",
ylab = "Stress")
plot(d$socmeduse, d$stress,
main="Scatterplot of Social Media Use and Stress",
xlab = "Social Media Use",
ylab = "Stress")
Boxplots
boxplot(data=d, swb~gender,
main="Boxplot of Satisfaction with Life and Gender",
xlab = "Gender",
ylab = "Satisfaction with Life")
boxplot(data=d, swb~age,
main="Boxplot of Satisfaction with Life and Age",
xlab = "Age",
ylab = "Satisfaction with Life")
Write-Up
If skew and kurtosis have issues: We reviewed plots and descriptive statistics for our six chosen variables. [One catigorical] variable had issues with skew and kurtosis: age scores were positively skewed (4.41) and was kurtotic (21.07). The other [continuous and other categorical] variables had skew and kurtosis within the accepted range (-2/+2).