# 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] "mindful" "socmeduse" "npi" "efficacy" "gender" "edu"
Univariate Plots: Histograms & Tables
#categorical here
table(d$gender)
f m nb
2312 784 53
table(d$edu)
1 High school diploma or less, and NO COLLEGE
57
2 Currently in college
2544
3 Completed some college, but no longer in college
35
4 Complete 2 year College degree
181
5 Completed Bachelors Degree
138
6 Currently in graduate education
135
7 Completed some graduate degree
59
# continuous go here
hist(d$mindful)
hist(d$socmeduse)
hist(d$npi)
hist(d$efficacy)
Univariate Normality
Check skew and kurtosis.
describe(d)
vars n mean sd median trimmed mad min max range skew
mindful 1 3149 3.71 0.84 3.73 3.72 0.79 1.13 6 4.87 -0.06
socmeduse 2 3149 34.47 8.57 35.00 34.74 7.41 11.00 55 44.00 -0.31
npi 3 3149 0.28 0.31 0.15 0.24 0.23 0.00 1 1.00 0.94
efficacy 4 3149 3.13 0.45 3.10 3.13 0.44 1.10 4 2.90 -0.24
gender* 5 3149 1.28 0.49 1.00 1.21 0.00 1.00 3 2.00 1.40
edu* 6 3149 2.50 1.25 2.00 2.18 0.00 1.00 7 6.00 2.19
kurtosis se
mindful -0.14 0.02
socmeduse 0.27 0.15
npi -0.69 0.01
efficacy 0.46 0.01
gender* 0.88 0.01
edu* 3.70 0.02
Bivariate Plots
Crosstabs
cross_cases(d, edu, gender)
gender | |||
---|---|---|---|
f | m | nb | |
edu | |||
1 High school diploma or less, and NO COLLEGE | 31 | 21 | 5 |
2 Currently in college | 1885 | 621 | 38 |
3 Completed some college, but no longer in college | 26 | 8 | 1 |
4 Complete 2 year College degree | 130 | 48 | 3 |
5 Completed Bachelors Degree | 99 | 36 | 3 |
6 Currently in graduate education | 103 | 30 | 2 |
7 Completed some graduate degree | 38 | 20 | 1 |
#Total cases | 2312 | 784 | 53 |
Scatterplots
plot(d$mindful, d$socmeduse,
main="Scatterplot of Mindfulness and Social Media Usage",
xlab = "Mindfulness",
ylab = "Social Media Usage")
plot(d$mindful, d$npi,
main="Scatterplot of Mindfulness and Narcissistic Personality",
xlab = "Mindfulness",
ylab = "Narcissistic Personality")
plot(d$mindful, d$efficacy,
main="Scatterplot of Mindfulness and Self-Efficacy",
xlab = "Mindfulness",
ylab = "Self-Efficacy")
plot(d$socmeduse, d$npi,
main="Scatterplot of Social Media Use and Narcissistic Personality",
xlab = "Social Media Use",
ylab = "Narscissistic Personality")
plot(d$socmeduse, d$efficacy,
main="Scatterplot of Social Media Use and Self-Efficacy",
xlab = "Social Media Use",
ylab = "Self-Efficacy")
plot(d$npi, d$efficacy,
main="Scatterplot of Narcissistic Personality and Self-Efficacy",
xlab = "Narcissistic Personality",
ylab = "Self-Efficacy")
Boxplots
# remember that continuous variabole comes first, CONTINOUS~CATEGORICAL
boxplot(data=d, socmeduse~gender,
main="Boxplot of Social Media Use and Gender",
xlab = "Gender",
ylab = "Social Media Use")
boxplot(data=d, npi~edu,
main="Boxplot of Narcissistic Personality and Education",
xlab = "Education",
ylab = "Narcissistic Personality")
Write-Up
We reviewed plots and descriptive statistics for our six chosen variables. All four of our continuous variables had skew and kurtosis within the accepted range (-2/+2). We created multiple different scatterplots that look at any correlation between our continous variables. We did not see any specific correlations between our continous variables; it mostly was weak correlations, if any. Most of the data appears to be uniform, no clear positive or negative trend. There is a slight negative trend in the relationship of social media use and self-efficacy: higher social media use may be associated with less efficacy, but it is not strong. There is also a weak positive correlation between mindfulness and efficacy. There may also be a weak negative correlation between mindfulness and social media use.