Basic Statistics HW

Load Libraries

# remember, you might need to install packages

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

Load Data

d <- read.csv(file="Data/mydata.csv", header=T)
names(d)
[1] "gender"               "age"                  "mfq_26"              
[4] "school_covid_support" "pss"                  "support"             

Univariate Plots: Histograms & Tables

table(d$gender) # UPDATE FOR HW!!!

            female I use another term               male  Prefer not to say 
                97                  2                 17                  2 
table(d$age)

         1 under 18 2 between 18 and 25 
                108                  10 
hist(d$mfq_26)

hist(d$school_covid_support)

hist(d$pss)

hist(d$support)

Univariate Normality

Check skew and kurtosis.

describe(d)
                     vars   n mean   sd median trimmed  mad  min  max range
gender*                 1 118 1.36 0.79   1.00    1.19 0.00 1.00 4.00  3.00
age*                    2 118 1.08 0.28   1.00    1.00 0.00 1.00 2.00  1.00
mfq_26                  3 118 4.15 0.61   4.20    4.14 0.67 2.60 5.65  3.05
school_covid_support    4 118 1.50 0.33   1.60    1.51 0.30 1.00 2.00  1.00
pss                     5 118 3.34 0.91   3.50    3.35 1.11 1.25 5.00  3.75
support                 6 118 3.40 0.98   3.33    3.42 0.99 1.17 5.00  3.83
                      skew kurtosis   se
gender*               1.87     1.87 0.07
age*                  2.94     6.73 0.03
mfq_26               -0.02    -0.32 0.06
school_covid_support -0.08    -1.19 0.03
pss                  -0.12    -0.85 0.08
support              -0.13    -0.92 0.09

Bivariate Plots

Crosstabs

cross_cases(d, gender, age)
 age 
 1 under 18   2 between 18 and 25 
 gender 
   I use another term  2
   Prefer not to say  2
   female  87 10
   male  17
   #Total cases  108 10

Scatterplots

plot(d$mfq_26, d$school_covid_support,
      main="Scatterplot of Mental Flexibility and School Covid Support",
      xlab = "Mental Flexibility",
      ylab = "Sschool Covid Support")

plot(d$mfq_26, d$pss,
      main="Scatterplot of Mental Flexibility and Stress",
      xlab = "Mental Flexibility",
      ylab = "Stress")

plot(d$mfq_26, d$support,
      main="Scatterplot of Mental Flexibility and Social Support",
      xlab = "Mental Flexibility",
      ylab = "Social Support")

plot(d$school_covid_support, d$pss,
      main="Scatterplot of School Covid Support and Stress",
      xlab = "School Covid Support",
      ylab = "Stress")

plot(d$school_covid_support, d$support,
      main="Scatterplot of School Covid Support and Social Support",
      xlab = "School Covid Support",
      ylab = "Social Support")

plot(d$pss, d$support,
      main="Scatterplot of Stress and Social Support",
      xlab = "Stress",
      ylab = "Social Support")

Boxplots

 boxplot(data=d, pss~gender,
         main="Boxplot of Stress and Gender",
         xlab = "Gender",
         ylab = "Stress")

boxplot(data=d, pss~age,
         main="Boxplot of Stress and Age",
         xlab = "Age ",
         ylab = "Stress")

Write-Up

If skew and kurtosis have issues: We reviewed plots and descriptive statistics for our six chosen variables. One variable had issues with skew and kurtosis: age scores were positively skewed (2.94) and were kurtotic (6.73). The other five variables had skew and kurtosis within the accepted range (-2/+2).