1 Loading Libraries

library(psych) # for the describe() command and the corr.test() command
library(apaTables) # to create our correlation table
library(kableExtra) # to create our correlation table

2 Importing Data

# import the dataset you cleaned previously
# this will be the dataset you'll use throughout the rest of the semester
# use ARC data downloaded previous for lab
d <- read.csv(file="Data/mydata.csv", header=T)

3 State Your Hypothesis

We predict that anxiety (measured by the GAD-7), worry (measured by the PSWQ), and pandemic-related anxiety (measured by the PAS) will all be negatively correlated with self-esteem (measured by the Rosenberg Self-Esteem Inventory). Furthermore, we predict that self-esteem will be lower in participants who report higher levels of generalized anxiety, greater worry, or higher pandemic-related anxiety.

4 Check Your Variables

# you only need to check the variables you're using in the current analysis
# although you checked them previously, it's always a good idea to look them over again and be sure that everything is correct
str(d)
## 'data.frame':    954 obs. of  6 variables:
##  $ age      : chr  "1 under 18" "1 under 18" "4 between 36 and 45" "4 between 36 and 45" ...
##  $ mhealth  : chr  "anxiety disorder" "none or NA" "none or NA" "none or NA" ...
##  $ rse      : num  1.6 3.9 1.7 3.9 2.4 1.8 3.5 3 3.5 2.5 ...
##  $ gad      : num  3.86 1.14 2 1.43 1.57 ...
##  $ pswq     : num  3.36 1.86 3.94 2.62 2.94 ...
##  $ pas_covid: num  4.56 3.33 4.22 3.22 3.56 ...
# since we're focusing on our continuous variables, we're going to subset them into their own dataframe. this will make some stuff we're doing later easier.
d2 <- subset(d, select=c(rse,gad,pswq,pas_covid))

# you can use the describe() command on an entire dataframe (d) or just on a single variable (d$pss)
describe(d2)
##           vars   n mean   sd median trimmed  mad min  max range  skew kurtosis
## rse          1 954 2.67 0.71   2.70    2.69 0.74   1 4.00  3.00 -0.21    -0.73
## gad          2 954 1.99 0.89   1.71    1.89 0.85   1 4.00  3.00  0.76    -0.57
## pswq         3 954 2.71 0.80   2.71    2.71 0.95   1 4.75  3.75  0.05    -0.76
## pas_covid    4 954 3.23 0.68   3.22    3.25 0.66   1 5.00  4.00 -0.23     0.12
##             se
## rse       0.02
## gad       0.03
## pswq      0.03
## pas_covid 0.02
# our fake variable has high kurtosis, which I'll ignore. you don't need to discuss univariate normality in the results write-ups for the labs/homework, but you will need to discuss it in your final manuscript

# also use histograms to examine your continuous variables
hist(d2$rse)

hist(d2$gad)

hist(d2$pswq)

hist(d2$pas_covid)

# last, use scatterplots to examine your continuous variables together
plot(d$rse, d$gad)

plot(d$rse, d$pswq)

plot(d$rse, d$pas_covid)

plot(d$gad, d$pswq)

plot(d$gad, d$pas_covid)

plot(d$pswq, d$pas_covid)

5 Check Your Assumptions

5.1 Pearson’s Correlation Coefficient Assumptions

  • Should have two measurements for each participant
  • Variables should be continuous and normally distributed
  • Outliers should be identified and removed
  • Relationship between the variables should be linear

5.1.1 Checking for Outliers

Note: You are not required to screen out outliers or take any action based on what you see here. This is something you will check and then discuss in your write-up.

d2$rse <- scale(d2$rse, center=T, scale=T)
hist(d2$rse)

sum(d2$rse < -3 | d2$rse > 3)
## [1] 0
d2$gad <- scale(d2$gad, center=T, scale=T)
hist(d2$gad)

sum(d2$gad < -3 | d2$gad > 3)
## [1] 0
d2$pswq <- scale(d2$pswq, center=T, scale=T)
hist(d2$pswq)

sum(d2$pswq < -3 | d2$pswq > 3)
## [1] 0
d2$pas_covid <- scale(d2$pas_covid, center=T, scale=T)
hist(d2$pas_covid)

sum(d2$pas_covid < -3 | d2$pas_covid > 3)
## [1] 1

5.2 Issues with My Data

Based on the descriptive statistics and histograms, all but one of my variables meet the assumptions for Pearson’s correlation coefficient. The variable Pandemic Anxiety Scale (pas_covid) had a slight kurtosis of 0.12 and contained one outlier. Outliers can distort the relationship between two variables and sway the correlation. Additionally, the Pandemic Anxiety Scale appears to have a non-linear relationship with some of the other variables. Pearson’s r may underestimate the strength of a non-linear relationship and distort the relationship direction. Therefore, any correlations involving the pas_covid measure should be interpreted with caution due to these potential distortions.

6 Run a Single Correlation

corr_output <- corr.test(d2$rse, d2$gad)

7 View Single Correlation

corr_output
## Call:corr.test(x = d2$rse, y = d2$gad)
## Correlation matrix 
##       [,1]
## [1,] -0.71
## Sample Size 
## [1] 954
## These are the unadjusted probability values.
##   The probability values  adjusted for multiple tests are in the p.adj object. 
##      [,1]
## [1,]    0
## 
##  To see confidence intervals of the correlations, print with the short=FALSE option

8 Create a Correlation Matrix

Strong: Between |0.50| and |1| Moderate: Between |0.30| and |0.49| Weak: Between |0.10| and |0.29| Trvial: Less than |0.09|

corr_output_m <- corr.test(d2)

9 View Test Output

corr_output_m
## Call:corr.test(x = d2)
## Correlation matrix 
##             rse   gad  pswq pas_covid
## rse        1.00 -0.71 -0.51     -0.30
## gad       -0.71  1.00  0.62      0.37
## pswq      -0.51  0.62  1.00      0.38
## pas_covid -0.30  0.37  0.38      1.00
## Sample Size 
## [1] 954
## Probability values (Entries above the diagonal are adjusted for multiple tests.) 
##           rse gad pswq pas_covid
## rse         0   0    0         0
## gad         0   0    0         0
## pswq        0   0    0         0
## pas_covid   0   0    0         0
## 
##  To see confidence intervals of the correlations, print with the short=FALSE option

10 Write Up Results

To test our hypothesis that anxiety (measured by the GAD-7), worry (measured by the PSWQ), and pandemic-related anxiety (measured by the PAS) will all be negatively correlated with self-esteem (measured by the Rosenberg Self-Esteem Inventory). and that we predict that self-esteem will be lower in participants who report higher levels of generalized anxiety, greater worry, or higher pandemic-related anxiety, we calculated a series of Pearson’s correlation coefficients. Most of uur data met the assumptions of the test, with all variables meeting the standards of normality and no outliers. One variable, Pandemic Anxiety Scale, did have an outlier and non-linear relationships with the other variables, and so any significant results involving that variable should be evaluated carefully.

As predicted, we found that all four variables were significantly correlated (all ps < .001). The effect sizes of the correlations varied, with several being large (rs > .5; Cohen, 1988). Specifically, self-esteem was strongly negatively correlated with generalized anxiety (r = -0.71) and worry (r = -0.51), both indicating large effect sizes. The correlation between self-esteem and pandemic-related anxiety, while significant, was of medium strength (r = -0.30). Generalized anxiety and worry were also strongly positively correlated (r = 0.62). Additionally, pandemic-related anxiety showed medium correlations with both generalized anxiety (r = 0.37) and worry (r = 0.38).

This test also supported our second hypothesis, that self-esteem would be lower in participants who are higher in anxiety or who report more symptoms of worry, as can be seen by the correlation coefficients reported in Table 1.

Table 1: Means, standard deviations, and correlations with confidence intervals
Variable M SD 1 2 3
Self-Esteem (RSE-10) 0.00 1.00
General Anxiety Disorder (GAD-7) -0.00 1.00 -.71**
[-.74, -.67]
Worry (PSWQ) -0.00 1.00 -.51** .62**
[-.56, -.47] [.58, .66]
Pandemic Anxiety (PAS_covid) 0.00 1.00 -.30** .37** .38**
[-.36, -.24] [.31, .42] [.32, .43]
Note:
M and SD are used to represent mean and standard deviation, respectively. Values in square brackets indicate the 95% confidence interval. The confidence interval is a plausible range of population correlations that could have caused the sample correlation.
* indicates p < .05
** indicates p < .01.

References

Cohen J. (1988). Statistical Power Analysis for the Behavioral Sciences. New York, NY: Routledge Academic.