# remember, you might need to install packages
library(psych) # for the describe() command
library(expss) # for the cross_cases() command
Basic Statistics Lab
Load Libraries
Load Data
<- read.csv(file="Data/mydata.csv", header=T)
d names(d)
[1] "income" "edu" "socmeduse" "stress"
[5] "moa_independence" "support"
Univariate Plots: Histograms & Tables
table(d$income)
1 low 2 middle 3 high rather not say
857 867 520 832
table(d$edu)
1 High school diploma or less, and NO COLLEGE
53
2 Currently in college
2495
3 Completed some college, but no longer in college
34
4 Complete 2 year College degree
175
5 Completed Bachelors Degree
132
6 Currently in graduate education
131
7 Completed some graduate degree
56
hist(d$socmeduse)
hist(d$stress)
hist(d$moa_independence)
hist(d$support)
Univariate Normality
Check skew and kurtosis.
describe(d)
vars n mean sd median trimmed mad min max range skew
income* 1 3076 2.43 1.16 2.00 2.41 1.48 1.0 4.0 3.0 0.15
edu* 2 3076 2.50 1.24 2.00 2.17 0.00 1.0 7.0 6.0 2.22
socmeduse 3 3076 34.44 8.59 35.00 34.72 7.41 11.0 55.0 44.0 -0.32
stress 4 3076 3.05 0.60 3.00 3.05 0.59 1.3 4.7 3.4 0.03
moa_independence 5 3076 3.54 0.46 3.67 3.61 0.49 1.0 4.0 3.0 -1.44
support 6 3076 5.54 1.12 5.75 5.66 0.99 0.0 7.0 7.0 -1.10
kurtosis se
income* -1.43 0.02
edu* 3.82 0.02
socmeduse 0.26 0.15
stress -0.16 0.01
moa_independence 2.52 0.01
support 1.46 0.02
Bivariate Plots
Crosstabs
cross_cases(d, income, edu)
edu | |||||||
---|---|---|---|---|---|---|---|
1 High school diploma or less, and NO COLLEGE | 2 Currently in college | 3 Completed some college, but no longer in college | 4 Complete 2 year College degree | 5 Completed Bachelors Degree | 6 Currently in graduate education | 7 Completed some graduate degree | |
income | |||||||
1 low | 19 | 615 | 14 | 73 | 54 | 64 | 18 |
2 middle | 8 | 721 | 14 | 42 | 36 | 25 | 21 |
3 high | 6 | 458 | 2 | 24 | 16 | 8 | 6 |
rather not say | 20 | 701 | 4 | 36 | 26 | 34 | 11 |
#Total cases | 53 | 2495 | 34 | 175 | 132 | 131 | 56 |
Scatterplots
plot(d$socmeduse, d$stress,
main="Scatterplot of Social Media Use and Stress",
xlab = "Social Media Use",
ylab = "Stress")
plot(d$socmeduse, d$moa_independence,
main="Scatterplot of Social Media Use and Independence",
xlab = "Social Media Use",
ylab = "Independence")
plot(d$socmeduse, d$support,
main="Scatterplot of Social Media Use and Social Support",
xlab = "Social Media Use",
ylab = "Social Support")
plot(d$stress, d$moa_independence,
main="Scatterplot of Stress and Independence",
xlab = "Stress",
ylab = "Independence")
plot(d$stress, d$support,
main="Scatterplot of Stress and Social Support",
xlab = "Stress",
ylab = "Social Support")
plot(d$moa_independence, d$support,
main="Scatterplot of Independence and Social Support",
xlab = "Independence",
ylab = "Social Support")
Boxplots
boxplot(data=d, stress~income,
main="Boxplot of Stress and Income",
xlab = "Income",
ylab = "Stress")
boxplot(data=d, moa_independence~income,
main="Boxplot of Independence and Income",
xlab = "Income",
ylab = "Independence")
Write-Up
We reviewed plots and descriptive statistics for our six chosen variables. The independence variable had issues with kurtosis with a score of 2.52, making it kurtotic. The other variables of social media use, stress, and social support had skew and kurtosis within the accepted range (-2/+2).