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

3 State Your Hypothesis

We predict that neuroticism (big5_neu), Pandemic Anxiety Scale (pas_covid), generalized anxiety (gad), and patient health questionnaire (phq) will all be correlated with each other. Furthermore, we predict that neuroticism and anxiety will be higher in participants who report more symptoms of depression.

4 have all 4 continous variables- use them all in hypothesis- can show direction of variableity or jsut say that they will be correlated with each other

5 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':    370 obs. of  8 variables:
##  $ income   : chr  "3 high" "2 middle" "2 middle" "2 middle" ...
##  $ mhealth  : chr  "none or NA" "none or NA" "none or NA" "anxiety disorder" ...
##  $ big5_neu : num  6 4 2.67 5.33 3.67 ...
##  $ pas_covid: num  3.22 4.22 3.22 4.56 3.67 ...
##  $ gad      : num  1.86 2 1.43 2.86 1.57 ...
##  $ phq      : num  1.33 2.33 1.11 2.33 1.56 ...
##  $ variable2: chr  "3 high" "2 middle" "2 middle" "2 middle" ...
##  $ variable3: chr  "none or NA" "none or NA" "none or NA" "anxiety disorder" ...
# 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(big5_neu,pas_covid,gad,phq))

# 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
## big5_neu     1 370 3.62 1.37   3.67    3.60 1.48 1.00 7.00  6.00 0.09    -0.72
## pas_covid    2 370 3.19 0.69   3.22    3.20 0.66 1.33 5.00  3.67 0.01    -0.04
## gad          3 370 1.54 0.61   1.43    1.43 0.42 1.00 4.00  3.00 1.60     2.49
## phq          4 370 1.50 0.52   1.33    1.41 0.33 1.00 3.78  2.78 1.67     3.15
##             se
## big5_neu  0.07
## pas_covid 0.04
## gad       0.03
## phq       0.03
# 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$big5_neu)

hist(d2$pas_covid)

hist(d2$gad)

hist(d2$phq)

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

plot(d2$big5_neu, d2$gad)

plot(d2$big5_neu, d2$phq)

plot(d2$pas_covid, d2$gad)

plot(d2$phq, d2$phq)

plot(d$gad, d$phq)

6 Check Your Assumptions

6.1 Pearson’s Correlation Coefficient Assumptions

  • Should have one measurement for each score for each participant

In our Data Prep and Basic Stats lab, we dropped any participants with missing data. So we’re good for this assumption!

  • Variables should be continuous and normally distributed

Checked in the section above!

  • Relationship between the variables should be linear

This one is a bit tricky! We’ll talk about it in class; feel free to take notes here.

  • Outliers should be identified and removed

We’ll do this one below.

6.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$big5_neu_std <- scale(d$big5_neu, center=T, scale=T)
hist(d$big5_neu_std)

sum(d$big5_neu_std < -3 | d$big5_neu_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] 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] 5
d$phq_std <- scale(d$phq, center=T, scale=T)
hist(d$phq_std)

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

6.2 Issues with My Data

All but two of my variables meet all of the assumptions of Pearson’s correlation coefficient. One variable, generalized anxiety measure (gad) had high kurtosis (2.49) and had 5 outliers. The other variable, measures depression (phq) had high kurtosis (3.15) and had 10 outliers. In total my data set has a 15 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 gad and phq should be evaluated carefully due to these risks.

7 Create a Correlation Matrix

corr_output_m <- corr.test(d2)

8 View Test Output

Effect size (r) curoffs: < .1 = trivial; <.3 = small; < .5 medium; > .5 large

corr_output_m
## Call:corr.test(x = d2)
## Correlation matrix 
##           big5_neu pas_covid  gad  phq
## big5_neu      1.00      0.38 0.52 0.42
## pas_covid     0.38      1.00 0.45 0.41
## gad           0.52      0.45 1.00 0.76
## phq           0.42      0.41 0.76 1.00
## Sample Size 
## [1] 370
## Probability values (Entries above the diagonal are adjusted for multiple tests.) 
##           big5_neu pas_covid gad phq
## big5_neu         0         0   0   0
## pas_covid        0         0   0   0
## gad              0         0   0   0
## phq              0         0   0   0
## 
##  To see confidence intervals of the correlations, print with the short=FALSE option

9 Write Up Results

To test our hypothesis that neuroticism symptoms (measured by the big5_neu), pandemic anxiety scale (measured by the pas_covid), generalized anxiety symptoms (measured by the gad), and depression symptoms (measured by the phq) would be correlated with one another, 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. Two variables, gad and phq, did have outliers 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 between big5_nue and gad, as well as gad and phq were all large correlations (rs > .5; Cohen, 1988). The rest of the effect sizes between pas_covid and big5_neu, phq and big5_neu, pas_covid and gad, and phq and pas_covid all have small correlations (rs > .3; Cohen, 1988). This test also supported our second hypothesis, we predict that neuroticism and anxiety will be higher in participants who report more symptoms of depression 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
Neuroticism (big5_neu) 3.62 1.37
Pandemic Anxiety Scale (pas_covid) 3.19 0.69 .38**
[.29, .46]
Generalized Anxiety (gad) 1.54 0.61 .52** .45**
[.44, .59] [.37, .53]
Depression Symptoms (phq) 1.50 0.52 .42** .41** .76**
[.33, .50] [.32, .49] [.72, .80]
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.