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

# update this for HW
d <- read.csv(file="Data/mydata.csv", header=T)
# names(d)

Univariate Plots: Histograms & Tables

table(d$gender)

            female I use another term               male  Prefer not to say 
               929                 31                179                 19 
table(d$sexual_orientation)

              Asexual                    Bi           Gay/Lesbian 
                   32                   144                    53 
Heterosexual/Straight    I use another term     Prefer not to say 
                  817                    34                    78 
# 
# hist(VARIABLE)
hist(d$big5_neu)

hist(d$edeq12)

hist(d$iou)

hist(d$rse)

Univariate Normality

Check skew and kurtosis.

describe(d)
                    vars    n mean   sd median trimmed  mad  min max range
edeq12                 1 1158 1.90 0.74   1.75    1.83 0.74 1.00   4  3.00
big5_neu               2 1158 4.39 1.52   4.67    4.44 1.48 1.00   7  6.00
gender*                3 1158 1.39 0.80   1.00    1.21 0.00 1.00   4  3.00
iou                    4 1158 2.57 0.91   2.43    2.52 0.96 1.04   5  3.96
sexual_orientation*    5 1158 3.79 1.02   4.00    3.81 0.00 1.00   6  5.00
rse                    6 1158 2.62 0.72   2.70    2.64 0.74 1.00   4  3.00
                     skew kurtosis   se
edeq12               0.69    -0.54 0.02
big5_neu            -0.30    -0.79 0.04
gender*              1.75     1.42 0.02
iou                  0.50    -0.60 0.03
sexual_orientation* -0.50     1.23 0.03
rse                 -0.22    -0.74 0.02

Bivariate Plots

Crosstabs

cross_cases(d, gender, sexual_orientation)
 sexual_orientation 
 Asexual   Bi   Gay/Lesbian   Heterosexual/Straight   I use another term   Prefer not to say 
 gender 
   I use another term  6 9 5 11
   Prefer not to say  2 3 1 2 11
   female  22 111 31 688 20 57
   male  4 22 14 128 1 10
   #Total cases  32 144 53 817 34 78

Scatterplots

plot(d$iou, d$rse,
     main="Scatterplot of Intolerance of Uncertainty and Self Esteem]",
     xlab = "Intolerance of Uncertainty",
     ylab = "Self-Esteem")

plot(d$iou, d$big5_neu,
     main="Scatterplot of Intolerance of Uncertainty and Neuroticism]",
     xlab = "Intolerance of Uncertainty",
     ylab = "Neuroticism")

plot(d$iou,d$edeq12,
     main="Scatterplot of Intolerance of Uncertainty and Eating Disorder Tendencies]",
     xlab = "Intolerance of Uncertainty",
     ylab = "Eating Disorder Tendencies")

  plot(d$rse, d$big5_neu,
     main="Scatterplot of Self Esteem and Neuroticism]",
     xlab = "Self Esteem",
     ylab = "Neuroticism")

plot(d$rse,d$edeq12,
     main="Scatterplot of Self-Esteem and Eating Disorder Tendencies]",
     xlab = "Self Esteem",
     ylab = "`Eating Disorder Tendencies")

plot(d$edeq12, d$big5_neu,
     main="Scatterplot of Eating Disorder Tendencies and Neuroticism]",
     xlab = "Eating Disorder Tendencies",
     ylab = "Neuroticism")

Boxplots

# remember that continous variable comes first
boxplot(data=d, iou~gender,
        main="Boxplot of Intolerance of Uncertainty and Pet Type",
        xlab = "Gender",
        ylab = "Intolerance of Uncertainty")

boxplot(data=d, iou~sexual_orientation,
        main="Boxplot of Intolerance of Uncertainty and Sexual Orientation",
        xlab = "Sexual Orientation",
        ylab = "Intolerance of Uncertainty")

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).