1 Loading Libraries

library(psych) # for the describe() command and the corr.test() command
library(apaTables) # to create our correlation table
## Warning: package 'apaTables' was built under R version 4.3.3
library(kableExtra) # to create our correlation table
## Warning: package 'kableExtra' was built under R version 4.3.3

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/Covid_Data_Final.csv", header=T)

3 State Your Hypothesis

I predict that those who show higher scores in their general anxiety (measured by the GAD) will likely show higher scores in both intolerance of uncertainty (measured by the IOU) and pandemic related anxiety (measured by the PAS). I also predict that those with higher scores in general anxiety will also report higher levels of depression (measured by the PHQ) due to the high comorbidity levels of both illnesses.

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':    1113 obs. of  6 variables:
##  $ health   : chr  "something else or not applicable" "something else or not applicable" "something else or not applicable" "two conditions" ...
##  $ mhealth  : chr  "none or NA" "anxiety disorder" "none or NA" "none or NA" ...
##  $ gad      : num  1.86 3.86 1.14 2 1.43 ...
##  $ phq      : num  1.33 3.33 1 2.33 1.11 ...
##  $ iou      : num  3.19 4 1.59 3.37 1.7 ...
##  $ pas_covid: num  3.22 4.56 3.33 4.22 3.22 ...
# 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.
cont <- subset(d, select=c(gad, phq, iou, pas_covid))

# you can use the describe() command on an entire dataframe (d) or just on a single variable (d$pss)
describe(cont)
##           vars    n mean   sd median trimmed  mad min max range  skew kurtosis
## gad          1 1113 2.04 0.92   1.71    1.95 0.85   1   4     3  0.69    -0.72
## phq          2 1113 2.07 0.87   1.89    1.99 0.99   1   4     3  0.64    -0.68
## iou          3 1113 2.56 0.91   2.41    2.50 0.99   1   5     4  0.51    -0.56
## pas_covid    4 1113 3.23 0.69   3.22    3.24 0.66   1   5     4 -0.18    -0.03
##             se
## gad       0.03
## phq       0.03
## iou       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(d$gad)

hist(d$phq)

hist(d$iou)

hist(d$pas_covid)

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

plot(d$gad, d$iou)

plot(d$gad, d$pas_covid)

plot(d$phq, d$iou)

plot(d$phq, d$pas_covid)

plot(d$iou, 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.

d$gad_std <- scale(d$gad, center=T, scale=T)
hist(d$gad_std)

sum(d$gad_std < -3 | d$gad_std > 3)
## [1] 0
d$phq_std <- scale(d$phq, center=T, scale=T)
hist(d$phq_std)

sum(d$phq_std < -3 | d$phq_std > 3)
## [1] 0
d$iou_std <- scale(d$iou, center=T, scale=T)
hist(d$iou_std)

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

sum(d$pas_covid_std < -3 | d$pas_covid_std > 3)
## [1] 1

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.

All but one of my variables meet all of the assumptions listed above regarding Pearson’s correlation coefficient. In the Pandemic Anxiety Scale (PAS), it showed one singular outlier. It seems to have a normal kurtosis and it seems to follow the others in terms of relationship. I am not positive how this will impact my correlations and while miniscule, it should be evaluated carefully nonetheless.

6 Create a Correlation Matrix

corr_output_m <- corr.test(cont)

7 View Test Output

corr_output_m
## Call:corr.test(x = cont)
## Correlation matrix 
##            gad  phq  iou pas_covid
## gad       1.00 0.84 0.71      0.40
## phq       0.84 1.00 0.64      0.34
## iou       0.71 0.64 1.00      0.39
## pas_covid 0.40 0.34 0.39      1.00
## Sample Size 
## [1] 1113
## Probability values (Entries above the diagonal are adjusted for multiple tests.) 
##           gad phq iou pas_covid
## gad         0   0   0         0
## phq         0   0   0         0
## iou         0   0   0         0
## pas_covid   0   0   0         0
## 
##  To see confidence intervals of the correlations, print with the short=FALSE option

8 Write Up Results

To test my hypothesis that general anxiety (measured by the GAD), depression (measured by the PHQ), intolerance of uncertainty (measured by the IOU), and pandemic related anxiety (measured by the PAS) would be correlated, we calculated a series of Pearson’s correlation coefficients. Most of, if not all, our data met the assumptions of the test save for one singular outlier in the PAS variable. While this would not seem to have much impact, it should still be evaluated carefully.

Following closely to most of my predictions, we see that all four variables are significantly correlated (all having p < .001). Most of the effect sizes were large (having r > .5; Cohen, 1988). However, going against my hypothesis, the PAS variable has a medium effect size instead with all of the other variables. While it is still related, it is not as closely related as I predicted. This can be seen in my Table below.

Table 1: Means, standard deviations, and correlations with confidence intervals
Variable M SD 1 2 3
Generalized Anxiety Disorder (GAD) 2.04 0.92
Depression symptoms (PHQ) 2.07 0.87 .84**
[.82, .86]
Intolerance of Uncertainty (IOU) 2.56 0.91 .71** .64**
[.67, .73] [.61, .68]
Pandemic Anxiety Scale (PAS) 3.23 0.69 .40** .34** .39**
[.35, .45] [.29, .39] [.34, .44]
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.