1 Loading Libraries

library(psych) # for the describe() command and the corr.test() command
## Warning: package 'psych' was built under R version 4.2.3
library(apaTables) # to create our correlation table
## Warning: package 'apaTables' was built under R version 4.2.3
library(kableExtra) # to create our correlation table
## Warning: package 'kableExtra' was built under R version 4.2.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/mydata.csv", header=T)

3 State Your Hypothesis

We predict that neuroticism (measured by the big5_neu), mental flexibility questionnaire as a trait (measured by the mfq_26), mental flexibility questionnaire as a state (measured by the mfq_state), and pandemic anxiety scale (measured by the pas_covid) will all be correlated with each other. Furthermore, we predict that neuroticism will be lower in participants who score higher in mental flexibility questionnaire as a trait or who report higher on the pandemic anxiety scale. We predict that neuroticism will be negatively correlated with mental flexibility as a trait and pandemic anxiety scale 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':    1207 obs. of  6 variables:
##  $ gender   : chr  "female" "male" "female" "female" ...
##  $ mhealth  : chr  "none or NA" "anxiety disorder" "none or NA" "none or NA" ...
##  $ big5_neu : num  6 6.67 4 4 2.67 ...
##  $ mfq_26   : num  4.2 3.35 4.65 4.65 4.5 4.3 5.25 4.45 5 4.7 ...
##  $ mfq_state: num  3.62 3 5.88 4 4.62 ...
##  $ pas_covid: num  3.22 4.56 3.33 4.22 3.22 ...
# 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,mfq_26,mfq_state,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
## big5_neu     1 1207 4.36 1.52   4.67    4.40 1.48 1.0   7   6.0 -0.28    -0.78
## mfq_26       2 1207 4.32 0.67   4.35    4.34 0.67 1.8   6   4.2 -0.34     0.22
## mfq_state    3 1207 4.11 0.98   4.25    4.17 0.93 1.0   6   5.0 -0.57     0.25
## pas_covid    4 1207 3.23 0.68   3.22    3.24 0.66 1.0   5   4.0 -0.18    -0.02
##             se
## big5_neu  0.04
## mfq_26    0.02
## mfq_state 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$big5_neu)

hist(d2$mfq_26)

hist(d2$mfq_state)

hist(d2$pas_covid)

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

plot(d$big5_neu, d$mfq_state)

plot(d$big5_neu, d$pas_covid)

plot(d$mfq_26, d$mfq_state)

plot(d$mfq_26, d$pas_covid)

plot(d$mfq_state, 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$big5_neu <- scale(d2$big5_neu, center=T, scale=T)
hist(d2$big5_neu)

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

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

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

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

5.2 Issues with My Data

All of my variables meet all of the assumptions of Pearson’s correlation coefficient. None of my variables had a high kurtosis. However the most deviated is neuroticism (big5_neu) with a kurtosis score of -0.78. Outliers can distort the relationship between two variables and sway the correlation in their direction. Luckily, none of the variables appear 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 neuroticism measurement should be evaluated carefully due to these risks.

6 Run a Single Correlation

corr_output <- corr.test(d2$mfq_26, d2$pas_covid)

7 View Single Correlation

corr_output
## Call:corr.test(x = d2$mfq_26, y = d2$pas_covid)
## Correlation matrix 
##       [,1]
## [1,] -0.19
## Sample Size 
## [1] 1207
## 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 
##           big5_neu mfq_26 mfq_state pas_covid
## big5_neu      1.00  -0.54     -0.56      0.33
## mfq_26       -0.54   1.00      0.76     -0.19
## mfq_state    -0.56   0.76      1.00     -0.25
## pas_covid     0.33  -0.19     -0.25      1.00
## Sample Size 
## [1] 1207
## Probability values (Entries above the diagonal are adjusted for multiple tests.) 
##           big5_neu mfq_26 mfq_state pas_covid
## big5_neu         0      0         0         0
## mfq_26           0      0         0         0
## mfq_state        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 stress (measured by the PSS-4), depression symptoms (measured by the PHQ-9), self-esteem (measured by the RSE-10), and fakeness (a fake measure FKE-3) would be correlated with one another, 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, fakeness, 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 three variables were significantly correlated (all ps < .001). The effect sizes of all correlations were large (rs > .5; Cohen, 1988). This test also supported our second hypothesis, that self-esteem would be lower in participants who are higher in stress or 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) -0.00 1.00
Mental Flexibility Questionnare (Trait) (mfq_26) 0.00 1.00 -.54**
[-.58, -.50]
Mental Flexibility Questionnare (State) (mfq_state) -0.00 1.00 -.56** .76**
[-.60, -.52] [.74, .79]
Pandemic Anxiety Scale (pas_covid) -0.00 1.00 .33** -.19** -.25**
[.28, .38] [-.24, -.13] [-.31, -.20]
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.