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] "mindful"   "swb"       "socmeduse" "race_rc"   "idea"      "income"   

Univariate Plots: Histograms & Tables

table(d$race_rc)

      asian       black    hispanic multiracial  nativeamer       other 
        209         243         282         291          12          94 
      white 
       2009 
table(d$income)

         1 low       2 middle         3 high rather not say 
           878            873            534            855 
# 
hist(d$mindful)

hist(d$swb)

hist(d$socmeduse)

hist(d$idea)

Univariate Normality

Check skew and kurtosis.

describe(d)
          vars    n  mean   sd median trimmed  mad   min max range  skew
mindful      1 3140  3.71 0.84   3.73    3.72 0.79  1.13   6  4.87 -0.06
swb          2 3140  4.47 1.32   4.67    4.53 1.48  1.00   7  6.00 -0.36
socmeduse    3 3140 34.47 8.56  35.00   34.75 7.41 11.00  55 44.00 -0.32
race_rc*     4 3140  5.54 2.12   7.00    5.88 0.00  1.00   7  6.00 -0.99
idea         5 3140  3.57 0.38   3.62    3.62 0.37  1.00   4  3.00 -1.52
income*      6 3140  2.44 1.16   2.00    2.42 1.48  1.00   4  3.00  0.14
          kurtosis   se
mindful      -0.14 0.02
swb          -0.45 0.02
socmeduse     0.26 0.15
race_rc*     -0.67 0.04
idea          4.30 0.01
income*      -1.44 0.02

Bivariate Plots

Crosstabs

cross_cases(d, race_rc, income)
 income 
 1 low   2 middle   3 high   rather not say 
 race_rc 
   asian  46 48 29 86
   black  86 60 21 76
   hispanic  101 102 16 63
   multiracial  99 79 47 66
   nativeamer  2 3 3 4
   other  29 15 8 42
   white  515 566 410 518
   #Total cases  878 873 534 855

Scatterplots

plot(d$mindful, d$swb,
     main="Scatterplot of Mindful Attention Awareness Scale and Satisfaction with Life Scale",
     xlab = "Mindful Attention Awareness Scale",
     ylab = "Satisfaction with Life Scale")

plot(d$mindful, d$socmeduse,
     main="Scatterplot of Mindful Attention Awareness Scale and Social Media Use",
     xlab = "Mindful Attention Awareness Scale",
     ylab = "Social Media Use")

plot(d$mindful, d$idea,
     main="Scatterplot of Mindful Attention Awareness Scale and IDEA",
     xlab = "Mindful Attention Awareness Scale",
     ylab = "IDEA")

plot(d$swb, d$socmeduse,
     main="Scatterplot of Satisfaction with Life Scale and Social Media Use",
     xlab = "Satisfaction with Life Scale",
     ylab = "Social Media Use")

plot(d$mindful, d$idea,
     main="Scatterplot of Mindful Attention Awareness Scale and IDEA",
     xlab = "Mindful Attention Awareness Scale",
     ylab = "IDEA")

plot(d$socmeduse, d$idea,
     main="Scatterplot of Social Media Use and IDEA",
     xlab = "Social Media Use",
     ylab = "IDEA")

Boxplots

# remember that continous variable comes first, CONTINUOUS-CATEGORICAL
boxplot(data=d, mindful~race_rc,
        main="Boxplot of Mindful Attention Awareness Scale and Race/Ethnicity",
        xlab = "Race/Ethnicity",
        ylab = "Mindful Attention Awareness Scale")

boxplot(data=d, mindful~income,
        main="Boxplot of Mindful Attention Awareness Scale and Income",
        xlab = "Mindful Attention Awareness Scale",
        ylab = "Income")

Write-Up

Once again, you need to create a write-up reviewing the most important things you did here. Again, it should be suitable for inclusion in a manuscript. Make sure you include your review of skewness and kurtosis. I have given you two potential templates you can follow below, depending upon your needs – you should delete the other text in this section and only include your write-up.

Skewness is the distribution of data in a graph plot; it can be either left tilt, right tilt, or centered. Kurtosis checks outliers and analyzes the data/distribution tails/tilt and rather or not they are heavy based on a normal distribution curve. If skew and kurtosis have issues: We reviewed plots and descriptive statistics for our six chosen variables. Intolerance of uncertainty and depression variables had issues with skew and/or kurtosis: worry scores were negatively skewed (-3.15) and self-esteem scores were kurtotic (2.50). The self-esteem and stress variables had skew and kurtosis within the accepted range (-2/+2).