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 the Negative Effects of COVID-19 will be correlated with Rosenberg Self-Esteem Inventory and Pandemic Anxiety Scale. Specifically, we hypothesize that individuals who experience higher levels of Negative Effects of COVID-19 will report lower levels of self-esteem and increased pandemic anxiety. Additionally, we predict that support (measured by the Support Measure) will moderate this relationship, such that individuals with higher levels of support will exhibit a weaker relationship between Negative Effects of COVID-19 and pandemic 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':    967 obs. of  6 variables:
##  $ gender   : chr  "male" "female" "female" "female" ...
##  $ pas_covid: num  4.56 3.33 4.22 3.22 3.56 ...
##  $ support  : num  2.17 5 2.5 3.67 3.83 ...
##  $ covid_neg: int  0 0 0 0 0 0 0 0 0 0 ...
##  $ rse      : num  1.6 3.9 1.7 3.9 2.4 1.8 3.5 3 3.5 2.5 ...
##  $ age      : chr  "1 under 18" "1 under 18" "4 between 36 and 45" "4 between 36 and 45" ...
# we're going to create a fake variable for this lab, so that it has four variables and mirrors the homework assignment. SKIP THIS STEP FOR THE HOMEWORK


# 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(pas_covid, support, rse, covid_neg))

# 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
## pas_covid    1 967 3.24 0.68   3.22    3.26 0.66   1   5     4 -0.22     0.13
## support      2 967 3.59 0.94   3.67    3.64 0.99   1   5     4 -0.41    -0.63
## rse          3 967 2.66 0.71   2.70    2.68 0.74   1   4     3 -0.23    -0.72
## covid_neg    4 967 1.05 1.75   0.00    0.70 0.00   0   8     8  1.45     0.92
##             se
## pas_covid 0.02
## support   0.03
## rse       0.02
## covid_neg 0.06
# 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$pas_covid)

hist(d2$support)

hist(d2$rse)

hist(d2$covid_neg)

# last, use scatterplots to examine your continuous variables together
plot(d2$support, d2$pas_covid)

plot(d2$support, d2$rse)

plot(d2$support, d2$covid_neg)

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$support <- scale(d2$support, center=T, scale=T)
hist(d2$support)

sum(d2$support < -3 | d2$support > 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
d2$covid_neg <- scale(d2$covid_neg, center=T, scale=T)
hist(d2$covid_neg)

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

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

5.2 Issues with My Data

All but one of my variables meet all of the assumptions of Pearson’s correlation coefficient. One variable, a fake measure of something fake (FKE-3) had high kurtosis (3.75) and had 31 outliers. Outliers can distort the relationship between two variables and sway the correlation in their direction. This variable also appears to have non-linear relationships with the other variables. Pearson’s r may underestimate the strength of a non-linear relationship and distort the relationship direction. Any correlations with my fake measure of fakeness should be evaluated carefully due to these risks.

6 Run a Single Correlation

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

7 View Single Correlation

corr_output
## Call:corr.test(x = d2$covid_neg, y = d2$rse)
## Correlation matrix 
##       [,1]
## [1,] -0.36
## Sample Size 
## [1] 967
## 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| Trivial: Less than |0.09|

corr_output_m <- corr.test(d2)

9 View Test Output

corr_output_m
## Call:corr.test(x = d2)
## Correlation matrix 
##           pas_covid support   rse covid_neg
## pas_covid      1.00   -0.16 -0.30      0.18
## support       -0.16    1.00  0.54     -0.21
## rse           -0.30    0.54  1.00     -0.36
## covid_neg      0.18   -0.21 -0.36      1.00
## Sample Size 
## [1] 967
## Probability values (Entries above the diagonal are adjusted for multiple tests.) 
##           pas_covid support rse covid_neg
## pas_covid         0       0   0         0
## support           0       0   0         0
## rse               0       0   0         0
## covid_neg         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 pandemic anxiety (measured by the Pandemic Anxiety Scale) and social support (measured by the Social Support Measure) would be correlated with each other, we calculated a Pearson’s correlation coefficient. Our data met the assumptions of the test, with all variables meeting the standards of normality and no outliers. As predicted, we found a significant negative correlation between pandemic anxiety and social support (r = -0.16, p < .001). The effect size of the correlation was small (Cohen, 1988). This supports our hypothesis that individuals with higher levels of pandemic anxiety report lower levels of social support. Additionally, we examined the relationship between pandemic anxiety and Rosenberg Self-Esteem Inventory (RSE), and found a significant negative correlation (r = -0.30, p < .001). This suggests that individuals with higher levels of pandemic anxiety tend to have lower levels of self-esteem. We also found a significant negative correlation between pandemic anxiety and COVID-19 negative effects (r = -0.36, p < .001), indicating that individuals with higher levels of pandemic anxiety are more likely to experience negative effects related to the pandemic. The relationship between COVID-19 negative effects and RSE was also significant, with a moderate correlation (r = 0.54, p < .001). This suggests that individuals who experience more negative effects related to the pandemic tend to have lower levels of self-esteem.

Table 1: Means, standard deviations, and correlations with confidence intervals
Variable M SD 1 2 3
Rosenberg Self-Esteem Inventory 0.00 1.00
Negative Effects of COVID-19 -0.00 1.00 -.16**
[-.22, -.10]
support -0.00 1.00 -.30** .54**
[-.35, -.24] [.49, .58]
Pandemic Anxiety Scale -0.00 1.00 .18** -.21** -.36**
[.12, .24] [-.27, -.14] [-.41, -.30]
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.