1 Loading Libraries

#install.packages("apaTables")
#install.packages("kableExtra")

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.5.3
library(kableExtra) # to create our correlation table
## Warning: package 'kableExtra' was built under R version 4.5.3

2 Importing Data

d <- read.csv(file="Data/projectdata.csv", header=T)

# For HW, import the your project dataset you cleaned previously; this will be the dataset you'll use throughout the rest of the semester

3 State Your Hypothesis

There will be a significant relationship between neuroticism, negative effects of COVID-19, and resilience. Specifically, neuroticism will be positively related to negative effects of COVID-19 and negatively related to resilience; and negative effects of COVID-19 will be negatively related to resilience.

4 Check Your Variables

# you only need to check the variables you're using in the current analysis
# it's always a good idea to look them to be sure that everything is correct
str(d)
## 'data.frame':    263 obs. of  7 variables:
##  $ X        : int  7888 7365 8747 7357 8760 8654 8272 8738 7911 8463 ...
##  $ exercise : chr  "2 1-2 hours" "2 1-2 hours" "2 1-2 hours" "2 1-2 hours" ...
##  $ mhealth  : chr  "none or NA" "none or NA" "none or NA" "none or NA" ...
##  $ covid_pos: int  12 1 7 5 5 9 8 3 4 9 ...
##  $ covid_neg: int  2 4 3 0 2 0 5 2 1 3 ...
##  $ big5_neu : num  6.67 4.33 2 4 3.33 ...
##  $ brs      : num  2 3.83 3.83 4 4.67 ...
# Since we're focusing only on our continuous variables, we're going to subset them into their own dataframe. This will make some stuff we're doing later on easier.

d2 <- subset(d, select=c(big5_neu, covid_neg, brs))

# 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 263 5.05 1.28   5.00    5.16 1.48   1   7     6 -0.69     0.00
## covid_neg    2 263 3.08 1.64   3.00    3.10 1.48   0   8     8 -0.06    -0.41
## brs          3 263 2.68 0.85   2.67    2.68 0.99   1   5     4  0.13    -0.56
##             se
## big5_neu  0.08
## covid_neg 0.10
## brs       0.05
# NOTE: Our fake variable has high kurtosis, which we'll ignore for the lab because we created it to be problematic. If you have high skew or kurtosis for any of your project variables, you will need to discuss it below in the Issues with My Data and Write up Results sections, as well as in your final project manuscript if your data does not meet the normality assumption.


# also use histograms to examine your continuous variables
# Because we are looking at 3 variables, we will have 3 histograms.

hist(d2$big5_neu)

hist(d2$covid_neg)

hist(d2$brs)

# last, use scatterplots to examine your continuous variables together, for each pairing
# because we are looking at 3 variables, we will have 3 pairings/plots. 

plot(d2$big5_neu,d2$covid_neg)

plot(d2$big5_neu, d2$brs)

plot(d2$covid_neg, d2$brs)

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: For correlations, you will NOT screen out outliers or take any action based on what you see here. This is something you will simply check and then discuss in your write-up.We will learn how to removed outliers in later analyses.

# We are going to standardize (z-score) all of our 3 variables, and check them for outliers.

 d2$big5_neu<- scale(d2$big5_neu, center=T, scale=T)
hist(d2$big5_neu)

sum(d2$big5_neu< -3 | d2$big5_neu > 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] 0
d2$brs<- scale(d2$brs, center=T, scale=T)
hist(d2$brs)

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

5.2 Issues with My Data

All three variables met the assumptions of Pearson’s correlation. Neuroticism had one outlier, while negative effects of COVID-19 and resilience had no outliers. Additionally, all variables showed acceptable levels of skewness and kurtosis, and scatterplots showed linear relationships between variables. Therefore, the assumptions of Pearson’s correlation were met.

6 Run a Single Correlation

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

7 View Single Correlation

corr_output
## Call:corr.test(x = d2$big5_neu, y = d2$covid_neg)
## Correlation matrix 
##      [,1]
## [1,] 0.06
## Sample Size 
## [1] 263
## These are the unadjusted probability values.
##   The probability values  adjusted for multiple tests are in the p.adj object. 
##      [,1]
## [1,] 0.37
## 
##  To see confidence intervals of the correlations, print with the short=FALSE option

8 Create a Correlation Matrix

corr_output_m <- corr.test(d2)

9 View Test Output

corr_output_m
## Call:corr.test(x = d2)
## Correlation matrix 
##           big5_neu covid_neg   brs
## big5_neu      1.00      0.06 -0.56
## covid_neg     0.06      1.00 -0.12
## brs          -0.56     -0.12  1.00
## Sample Size 
## [1] 263
## Probability values (Entries above the diagonal are adjusted for multiple tests.) 
##           big5_neu covid_neg  brs
## big5_neu      0.00      0.37 0.00
## covid_neg     0.37      0.00 0.11
## brs           0.00      0.05 0.00
## 
##  To see confidence intervals of the correlations, print with the short=FALSE option
# Remember to report the p-values from the matrix that are ABOVE the diagonal!

Remember, Pearson’s r is also an effect size! We don’t report effect sizes for non-sig correlations.

  • 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|

10 Write Up Results

To test our hypothesis that neuroticism, negative effects of COVID-19, and resilience would be correlated with one another, we calculated a series of Pearson’s correlation coefficients. Two variables met the required assumptions of the test, with no outliers. However, the neuroticism variable did show one outlier.

Results showed that neuroticism was not significantly related to negative effects of COVID-19 (p=.37). However, neuroticism was significantly negatively related to resilience (p< .001), indicating a strong effect. Additionally, negative effects of COVID-19 were not significantly related to resilience (p=.11).

Overall, these findings partially support my hypothesis. While the predicted negative relationship between neuroticism and resilience was supported, the expected relationships between neuroticism and negative COVID-19 effects, and between negative COVID-19 effects and resilience, were not supported. The effect size of neuroticism and negative effects of COVID-19 was trivial (less than .09), the effect size of neuroticism and resilience was strong (between 0.50 and 1), and the effect size between the negative effects of COVID-19 and resilience was weak (between 0.10 and 0.29).

Table 1: Means, standard deviations, and correlations with confidence intervals
Variable M SD 1 2
Neuroticism 5.05 1.28
Negative COVID-19 Effects 3.08 1.64 .06
[-.07, .18]
Resilience 2.68 0.85 -.56** -.12
[-.63, -.47] [-.24, .00]
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.