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
library(kableExtra) # to create our correlation table

2 Importing Data

d <- read.csv(file="../Final Project/Data/arc_data_final_SP26.csv", header=T)
getwd()
## [1] "/Users/hanapar/Library/CloudStorage/OneDrive-IndianaUniversity/M311 Lab in Social Psych/Research/Labs"
# 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 openness, agreeableness, and negative effects of COVID-19. Specifically, openness will be negatively related to negative effects of COVID-19 and agreeableness will be negatively related to the negative effects of COVID-19.

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':    996 obs. of  40 variables:
##  $ X                   : int  520 2814 3146 3295 717 6056 4753 5365 2044 1965 ...
##  $ gender              : chr  "female" "male" "female" "male" ...
##  $ trans               : chr  "no" "no" "no" "no" ...
##  $ sexual_orientation  : chr  "Prefer not to say" "Heterosexual/Straight" "Heterosexual/Straight" "Heterosexual/Straight" ...
##  $ ethnicity           : chr  "Prefer not to say" "White - British, Irish, other" "Asian/Asian British - Indian, Pakistani, Bangladeshi, other" "Asian/Asian British - Indian, Pakistani, Bangladeshi, other" ...
##  $ relationship_status : chr  "Single, never married" "Single, never married" "Prefer not to say" "Single, never married" ...
##  $ age                 : chr  "1 under 18" "1 under 18" "1 under 18" "1 under 18" ...
##  $ urban_rural         : chr  "town" "town" "town" "town" ...
##  $ income              : chr  NA NA NA NA ...
##  $ education           : chr  "1 equivalent to not completing high school" "prefer not to say" "2 equivalent to high school completion" "prefer not to say" ...
##  $ employment          : chr  "1 high school equivalent" "1 high school equivalent" "1 high school equivalent" "1 high school equivalent" ...
##  $ treatment           : chr  NA "not in treatment" NA "no psychological disorders" ...
##  $ health              : chr  "something else or not applicable" "something else or not applicable" "prefer not to say" "lung disease" ...
##  $ mhealth             : chr  "none or NA" "none or NA" "none or NA" "none or NA" ...
##  $ sleep_hours         : chr  "2 5-6 hours" "3 7-8 hours" "2 5-6 hours" "4 8-10 hours" ...
##  $ exercise            : chr  "1 less than 1 hour" "1 less than 1 hour" "1 less than 1 hour" "1 less than 1 hour" ...
##  $ pet                 : chr  "cat" "other" "no pets" "no pets" ...
##  $ covid_pos           : int  0 0 0 0 0 0 0 0 0 0 ...
##  $ covid_neg           : int  0 0 0 0 0 0 0 0 0 0 ...
##  $ big5_open           : num  3.67 4.33 5.67 6 5.67 ...
##  $ big5_con            : num  3 4 6 4 3.33 ...
##  $ big5_agr            : num  4.33 2.67 5.67 5.67 5 ...
##  $ big5_neu            : num  5.33 2.67 1 3.67 4.33 ...
##  $ big5_ext            : num  2 2.67 4.67 4.33 1.67 ...
##  $ pswq                : num  2.71 1.43 1.86 1.79 2.36 ...
##  $ iou                 : num  2.22 1.52 1.78 1.85 2.22 ...
##  $ mfq_26              : num  2.7 4.55 4.8 3.8 4.5 4 5.8 4.2 4.5 5.25 ...
##  $ mfq_state           : num  3 4.38 4.88 4.88 4.88 ...
##  $ rse                 : num  2.6 3.1 3.7 3 3 3 4 3.8 2.5 4 ...
##  $ school_covid_support: num  NA NA NA NA NA NA NA NA NA NA ...
##  $ school_att          : num  NA NA NA NA NA NA NA NA NA NA ...
##  $ pas_covid           : num  3 3.44 4.67 2.44 1.56 ...
##  $ pss                 : num  2.75 2.25 3 2 1.75 2 1 1.25 3 1.25 ...
##  $ phq                 : num  1.56 1.44 1.11 1.33 1.44 ...
##  $ gad                 : num  1.14 1.29 1 1 1.14 ...
##  $ edeq12              : num  1.33 1.08 1 1 1.17 ...
##  $ brs                 : num  NA NA NA NA NA NA NA NA NA NA ...
##  $ swemws              : num  3 2.86 4 3.57 3.86 ...
##  $ isolation_c         : num  1 1 1 1 1 1 1 1 1 1 ...
##  $ support             : num  2.83 3 4 4 3.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_open, big5_agr, covid_neg))

# 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_open    1 950 5.26 1.13   5.33    5.35 0.99   1   7     6 -0.79     0.66
## big5_agr     2 953 4.86 1.14   5.00    4.90 0.99   1   7     6 -0.35    -0.05
## covid_neg    3 996 1.63 2.03   0.00    1.34 0.00   0   8     8  0.86    -0.52
##             se
## big5_open 0.04
## big5_agr  0.04
## covid_neg 0.06
# 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(d$big5_open)

hist(d$big5_agr)

hist(d$covid_neg)

# 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(d$big5_open, d$big5_agr)

plot(d$big5_open, d$covid_neg)

plot(d$big5_agr, d$covid_neg)

5 Check Your Assumptions

5.1 Pearson’s Correlation Coefficient Assumptions

  • Should have all measurement 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_open <- scale(d2$big5_open, center=T, scale=T)
hist(d$big5_open)

sum(d2$big5_open < -3 | d2$big5_open > 3, na.rm=T)
## [1] 6
d2$big5_agr <- scale(d2$big5_agr, center=T, scale=T)
hist(d$big5_agr)

sum(d2$big5_agr < -3 | d2$big5_agr > 3, na.rm=T)
## [1] 3
d2$covid_neg <- scale(d2$covid_neg, center=T, scale=T)
hist(d$covid_neg)

sum(d2$covid_neg < -3 | d2$covid_neg > 3, na.rm=T)
## [1] 4

5.2 Issues with My Data

Two of my variables meet all of the assumptions of Pearson’s correlation coefficient. One variable, openness had 6 outliers and one variable, agreeableness had 3 outliers. Outliers can distort the relationship between two variables and sway the correlation in their direction. The three variables do not appear to have non-linear relationships with each other. Pearson’s r may underestimate the strength of a non-linear relationship and distort the relationship direction. Any correlations with these variables should be evaluated carefully due to these risks.

6 Run a Single Correlation

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

7 Second Correlation

corr_output2 <- corr.test(d2$big5_agr, d2$covid_neg)

# View Single Correlation
corr_output
## Call:corr.test(x = d2$big5_open, y = d2$covid_neg)
## Correlation matrix 
##      [,1]
## [1,] 0.02
## Sample Size 
## [1] 950
## These are the unadjusted probability values.
##   The probability values  adjusted for multiple tests are in the p.adj object. 
##      [,1]
## [1,] 0.58
## 
##  To see confidence intervals of the correlations, print with the short=FALSE option
corr_output2
## Call:corr.test(x = d2$big5_agr, y = d2$covid_neg)
## Correlation matrix 
##       [,1]
## [1,] -0.02
## Sample Size 
## [1] 953
## These are the unadjusted probability values.
##   The probability values  adjusted for multiple tests are in the p.adj object. 
##      [,1]
## [1,] 0.48
## 
##  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_open big5_agr covid_neg
## big5_open      1.00     0.07      0.02
## big5_agr       0.07     1.00     -0.02
## covid_neg      0.02    -0.02      1.00
## Sample Size 
##      [,1] [,2] [,3]
## [1,]  950  948  950
## [2,]  948  953  953
## [3,]  950  953  996
## Probability values (Entries above the diagonal are adjusted for multiple tests.) 
##           big5_open big5_agr covid_neg
## big5_open      0.00     0.09      0.96
## big5_agr       0.03     0.00      0.96
## covid_neg      0.58     0.48      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 openness, agreeableness, and negative effects of COVID-19 would be correlated with correlated with one another, we calculated a series of Pearson’s correlation coefficients. Two of the variables (openness and agreeableness) met the required assumptions of the test, with both meeting the standards of normality. One variable, negative effects of COVID-19, had 4 outliers. Openness had 6 outliers and agreeableness had 3 outliers; so any significant results involving these variables should be evaluated carefully .

We found that openness was not significantly correlated with negative effects of COVID-19 (r = .02, p = .96), and agreeableness was not significantly correlated with negative effects of COVID-19 (r = -.02, p = .96) Therefore, neither predicted relationship was supported. Please refer to the correlation coefficients reported in Table 1.

Table 1: Means, standard deviations, and correlations with confidence intervals
Variable M SD 1 2
Openness 5.26 1.13
Agreeableness 4.86 1.14 .07*
[.01, .13]
Negative Effects of COVID-19 1.63 2.03 .02 -.02
[-.05, .08] [-.09, .04]
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.