Basic Statistics Lab

Load Libraries

# remember, you might need to install packages

library(psych) # for the describe() command
library(expss) # for the cross_cases() command

Load Data

#WILL NEED TO UPDATE THIS FOR THE HW!!! USE MYDATA
d <- read.csv(file="Data/mydata.csv", header=T)
names(d)
[1] "swb"     "income"  "sibling" "mindful" "belong"  "stress" 

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$belong)

hist(d$stress)

hist(d$swb)

Univariate Normality

Check skew and kurtosis.

describe(d)
         vars    n mean   sd median trimmed  mad  min max range  skew kurtosis
swb         1 3142 4.47 1.32   4.67    4.53 1.48 1.00 7.0  6.00 -0.36    -0.45
income*     2 3142 2.43 1.16   2.00    2.42 1.48 1.00 4.0  3.00  0.15    -1.44
sibling*    3 3142 1.10 0.29   1.00    1.00 0.00 1.00 2.0  1.00  2.75     5.57
mindful     4 3142 3.71 0.84   3.73    3.71 0.79 1.13 6.0  4.87 -0.06    -0.15
belong      5 3142 3.23 0.60   3.30    3.25 0.59 1.30 5.0  3.70 -0.26    -0.12
stress      6 3142 3.05 0.60   3.00    3.05 0.59 1.30 4.7  3.40  0.03    -0.16
           se
swb      0.02
income*  0.02
sibling* 0.01
mindful  0.02
belong   0.01
stress   0.01
# cut offs are between -2 and +2

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$belong,
     main="Scatterplot of Mindfulness and Need to Belong",
     xlab = "Mindfulness",
     ylab = "Need to Belong")

plot(d$mindful, d$stress,
     main="Scatterplot of Mindfulness and Stress",
     xlab = "Mindfulness",
     ylab = "Stress")

plot(d$mindful, d$swb,
     main="Scatterplot of Mindfulness and Satisfaction With Life Scale",
     xlab = "Mindfulness",
     ylab = "Satisfaction With Life Scale")

plot(d$belong, d$stress,
     main="Scatterplot of Belong and Stress",
     xlab = "Belong",
     ylab = "Stress")

plot(d$belong, d$swb,
     main="Scatterplot of Belong and Satisfaction With Life Scale",
     xlab = "Belong",
     ylab = "Satisfaction With Life Scale")

plot(d$stress, d$swb,
     main="Scatterplot of Stress and Satisfaction with Life Scale",
     xlab = "Stress",
     ylab = "Satisfaction with Life Scale")

Boxplots

#remeber that continous variable comes first, CONTINOUS~CATEGORICAL
boxplot(data=d, mindful~income,
        main="Boxplot of Mindfulness and Income",
        xlab = "Income",
        ylab = "Mindfulness")

boxplot(data=d, mindful~sibling,
        main="Boxplot of Mindfulness and Siblings",
        xlab = "Siblings",
        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).