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
library(naniar)

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/jenna_data.csv", header=T)
# use the gg_miss_upset() command for a visualization of your missing data
gg_miss_upset(d[-1], nsets = 6)

# use the na.omit() command to create a new dataframe in which any participants with missing data are dropped from the dataframe
d <- na.omit(d)

3 State Your Hypothesis

We predict that worry (measured by the PSWQ), anxiety symptoms (measured by the GAD), extraversion (measured by the Big 5 Extraversion), and COVID positivity (measured by survery) will all be correlated with each other. Furthermore, we predict that worry will be higher in participants who are higher in anxiety symptoms or who report lower extraversion scores.

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':    326 obs. of  7 variables:
##  $ X           : int  1 31 49 57 86 113 133 179 190 208 ...
##  $ income      : chr  "3 high" "2 middle" "2 middle" "2 middle" ...
##  $ exercise_cat: chr  "1 less than 1 hour" "2 1-2 hours" "2 1-2 hours" "2 1-2 hours" ...
##  $ covid_pos   : int  0 0 0 0 0 0 0 0 0 0 ...
##  $ big5_ext    : num  2 5 5.67 4 5.33 ...
##  $ pswq        : num  4.94 3.94 2.94 2.81 3.5 ...
##  $ gad         : num  1.86 2 1.57 2.86 1.57 ...
##  - attr(*, "na.action")= 'omit' Named int [1:1747] 2 3 5 6 7 10 11 12 13 14 ...
##   ..- attr(*, "names")= chr [1:1747] "2" "3" "5" "6" ...
# 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(covid_pos, pswq, gad, big5_ext))

# 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
## covid_pos    1 326 0.23 1.14   0.00    0.00 0.00 0.00 12.00 12.00  6.57
## pswq         2 326 2.87 0.87   2.81    2.85 1.02 1.12  4.94  3.81  0.20
## gad          3 326 1.53 0.61   1.43    1.42 0.42 1.00  4.00  3.00  1.73
## big5_ext     4 326 4.64 1.33   4.67    4.72 1.48 1.33  7.00  5.67 -0.43
##           kurtosis   se
## covid_pos    50.61 0.06
## pswq         -0.79 0.05
## gad           3.22 0.03
## big5_ext     -0.58 0.07
# 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$covid_pos)

hist(d$pswq)

hist(d$gad)

hist(d$big5_ext)

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

plot(d$covid_pos, d$gad)

plot(d$covid_pos, d$big5_ext)

plot(d$pswq, d$gad)

plot(d$pswq, d$big5_ext)

plot(d$gad, d$big5_ext)

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$pswq_std <- scale(d$pswq, center=T, scale=T)
hist(d$pswq_std)

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

sum(d$gad_std < -3 | d$gad_std > 3)
## [1] 6
d$big5_ext_std <- scale(d$big5_ext, center=T, scale=T)
hist(d$big5_ext_std)

sum(d$big5_ext_std < -3 | d$big5_ext_std > 3)
## [1] 0
d$covid_pos_std <- scale(d$covid_pos, center=T, scale=T)
hist(d$covid_pos_std)

sum(d$covid_pos_std < -3 | d$covid_poss_std > 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 Create a Correlation Matrix

corr_output_m <- corr.test(cont)

7 View Test Output

corr_output_m
## Call:corr.test(x = cont)
## Correlation matrix 
##           covid_pos  pswq   gad big5_ext
## covid_pos      1.00  0.07 -0.01    -0.01
## pswq           0.07  1.00  0.59    -0.13
## gad           -0.01  0.59  1.00    -0.11
## big5_ext      -0.01 -0.13 -0.11     1.00
## Sample Size 
## [1] 326
## Probability values (Entries above the diagonal are adjusted for multiple tests.) 
##           covid_pos pswq  gad big5_ext
## covid_pos      0.00 0.57 1.00     1.00
## pswq           0.19 0.00 0.00     0.07
## gad            0.91 0.00 0.00     0.16
## big5_ext       0.87 0.01 0.04     0.00
## 
##  To see confidence intervals of the correlations, print with the short=FALSE option

8 Write Up Results

To test our hypothesis that worry (measured by the PSWQ), anxiety symptoms (measured by the GAD), extraversion (measured by the Big 5 Extraversion), and COVID positivity (measured by survery) will all be correlated with each other, we calculated a series of Pearson’s correlation coefficients. Most of our data met the assumptions of the test, with all variables meeting the standards of normality and no outliers. One variable, GAD, did have 6 outliers and non-linear relationships with the other variables, and so any significant results involving that variable should be evaluated carefully.

As we didn’t predict, we found that two variables (GAD, PSWQ) were significantly correlated (ps < .001). The effect sizes of all correlations were large (rs > .5; Cohen, 1988). This test also supported one part of our second hypothesis, that worry would be higher in participants who are higher in anxiety, as can be seen by the correlation coefficients reported in Table 1.

The relationship between worry (PSWQ) and GAD was positive, “r”(326) = 0.59, “p” = < .001.

Table 1: Means, standard deviations, and correlations with confidence intervals
Variable M SD 1 2 3
COVID Positvity 0.23 1.14
Worry symptoms (PSWQ) 2.87 0.87 .07
[-.04, .18]
Anxiety symptoms (GAD) 1.53 0.61 -.01 .59**
[-.11, .10] [.51, .65]
Extraversion (Big 5) 4.64 1.33 -.01 -.13* -.11*
[-.12, .10] [-.24, -.03] [-.22, -.01]
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.