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] "gender"           "phys_sym"         "moa_independence" "swb"             
[5] "belong"           "stress"          

Univariate Plots: Histograms & Tables

table(d$gender)

   f    m   nb 
2267  771   52 
table(d$phys_sym)

  high number of symptoms    low number of symptoms medium number of symptoms 
                      854                       581                      1655 
hist(d$moa_independence)

hist(d$swb)

hist(d$belong)

hist(d$stress)

Univariate Normality

Check skew and kurtosis.

describe(d)
                 vars    n mean   sd median trimmed  mad min max range  skew
gender*             1 3090 1.28 0.49   1.00    1.21 0.00 1.0 3.0   2.0  1.39
phys_sym*           2 3090 2.26 0.86   3.00    2.32 0.00 1.0 3.0   2.0 -0.52
moa_independence    3 3090 3.54 0.47   3.67    3.61 0.49 1.0 4.0   3.0 -1.44
swb                 4 3090 4.47 1.32   4.67    4.53 1.48 1.0 7.0   6.0 -0.37
belong              5 3090 3.23 0.61   3.30    3.25 0.59 1.3 5.0   3.7 -0.26
stress              6 3090 3.05 0.60   3.00    3.05 0.59 1.3 4.7   3.4  0.03
                 kurtosis   se
gender*              0.87 0.01
phys_sym*           -1.46 0.02
moa_independence     2.52 0.01
swb                 -0.45 0.02
belong              -0.13 0.01
stress              -0.17 0.01

Bivariate Plots

Crosstabs

cross_cases(d, gender, phys_sym)
 phys_sym 
 high number of symptoms   low number of symptoms   medium number of symptoms 
 gender 
   f  708 314 1245
   m  120 264 387
   nb  26 3 23
   #Total cases  854 581 1655

Scatterplots

plot(d$moa_independence, d$swb,
      main="Scatterplot of Markers of Adulthood and Satisfaction With Life",
      xlab = "Markers of Adulthood",
      ylab = "Satisfaction With Life")

plot(d$moa_independence, d$belong,
      main="Scatterplot of Markers of Adulthood and Need to Belong",
      xlab = "Markers of Adulthood",
      ylab = "Need to Belong")

plot(d$moa_independence, d$stress,
      main="Scatterplot of Markers of Adulthood and Perceived Stress",
      xlab = "Markers of Adulthood",
      ylab = "Perceived Stress")

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

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

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

Boxplots

# remember that continuous variable comes firts, CONTINUOUS~CATEGORICAL
 boxplot(data=d, moa_independence~gender,
         main="Boxplot of Markers of Adulthood and Gender",
         xlab = "Gender",
         ylab = "Markers of Adulthood")

 boxplot(data=d, moa_independence~phys_sym,
         main="Boxplot of Markers of Adulthood and Physical Symptoms",
         xlab = "Physical Symptoms",
         ylab = "Markers of Adulthood")

Write-Up

We reviewed plots and descriptive statistics for our six chosen variables. Markers of adulthood variable had issues with kurtosis: markers of adulthood scores were kurtotic (2.52). The other five variables had skew and kurtosis within the accepted range (-2/+2).