# remember, you might need to install packages
library(psych) # for the describe() command
library(expss) # for the cross_cases() commandBasic Statistics Lab
Load Libraries
Load Data
# WILL NEED TO UPDATE THIS FOR THE HW!!! USE MYDATA
d <- read.csv(file="Data/mydata.csv", header=T)
names(d)[1] "sibling" "income" "mindful" "swb" "stress" "belong"
Univariate Plots: Histograms & Tables
table(d$sibling)
at least one sibling only child
2842 300
table(d$income)
1 low 2 middle 3 high rather not say
877 877 535 853
#
hist(d$mindful)hist(d$swb)hist(d$stress)hist(d$belong)Univariate Normality
Check skew and kurtosis.
describe(d) vars n mean sd median trimmed mad min max range skew kurtosis
sibling* 1 3142 1.10 0.29 1.00 1.00 0.00 1.00 2.0 1.00 2.75 5.57
income* 2 3142 2.43 1.16 2.00 2.42 1.48 1.00 4.0 3.00 0.15 -1.44
mindful 3 3142 3.71 0.84 3.73 3.71 0.79 1.13 6.0 4.87 -0.06 -0.15
swb 4 3142 4.47 1.32 4.67 4.53 1.48 1.00 7.0 6.00 -0.36 -0.45
stress 5 3142 3.05 0.60 3.00 3.05 0.59 1.30 4.7 3.40 0.03 -0.16
belong 6 3142 3.23 0.60 3.30 3.25 0.59 1.30 5.0 3.70 -0.26 -0.12
se
sibling* 0.01
income* 0.02
mindful 0.02
swb 0.02
stress 0.01
belong 0.01
Bivariate Plots
Crosstabs
cross_cases(d, sibling, income)| income | ||||
|---|---|---|---|---|
| 1 low | 2 middle | 3 high | rather not say | |
| sibling | ||||
| at least one sibling | 790 | 795 | 489 | 768 |
| only child | 87 | 82 | 46 | 85 |
| #Total cases | 877 | 877 | 535 | 853 |
Scatterplots
plot(d$mindful, d$swb,
main="Scatterplot of Mindfulness and Satisfaction with Life",
xlab = "Mindfulness",
ylab = "Satisfaction with Life")plot(d$mindful, d$stress,
main="Scatterplot of Mindfulness and Perceived Stress",
xlab = "Mindfulness",
ylab = "Perceived Stress")plot(d$mindful, d$belong,
main="Scatterplot of Mindfulness and Sense of Belonging",
xlab = "Mindfulness",
ylab = "Sense of Belonging")plot(d$swb, d$stress,
main="Scatterplot of Satisfaction with Life and Perceived Stress",
xlab = "Satisfaction with Life",
ylab = "Perceived Stress")plot(d$swb, d$belong,
main="Scatterplot of Satisfaction with Life and Sense of Belonging",
xlab = "Satisfaction with Life",
ylab = "Sense of Belonging")plot(d$stress, d$belong,
main="Scatterplot of Perceived Stress and Sense of Belonging",
xlab = "Perceived Stress",
ylab = "Sense of Belonging")Boxplots
# remember that continuous variale comes first, CONTINUOUS~CATEGORICAL
boxplot(data=d, mindful~sibling,
main="Boxplot of Intolerance of Uncertainty and Pet Type",
xlab = "Sibling Status",
ylab = "Mindfulness")boxplot(data=d, mindful~income,
main="Boxplot of Intolerance of Uncertainty and Mental Health Diagnosis",
xlab = "Income",
ylab = "Mindfulness")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).