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

3 State Your Hypothesis

We hypothesize that negative covid symptoms, worry symptoms (measured by the pswq), intolerance of uncertainty (measured by the iou), and symptoms of disordered eating (measured by the edeq12) will all be correlated with each other. Furthermore, we predict that worry symptoms will be higher in participants who are higher in intolerance of uncertainty or who report more symptoms of disordered eating.

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':    329 obs. of  6 variables:
##  $ gender   : chr  "female" "female" "female" "female" ...
##  $ income   : chr  "3 high" "2 middle" "2 middle" "2 middle" ...
##  $ covid_neg: int  0 0 0 0 0 0 0 0 0 0 ...
##  $ pswq     : num  4.94 3.94 2.62 2.94 2.81 ...
##  $ iou      : num  3.19 3.37 1.7 1.89 1.11 ...
##  $ edeq12   : num  1.58 1.67 1.42 1.33 3.17 ...
# 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(covid_neg,pswq,iou,edeq12))

# 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
## covid_neg    1 329 0.20 0.78   0.00    0.00 0.00 0.00 5.00  5.00 4.16    17.21
## pswq         2 329 2.88 0.88   2.88    2.86 1.02 1.12 4.94  3.81 0.18    -0.82
## iou          3 329 2.19 0.69   2.07    2.13 0.71 1.04 4.44  3.41 0.71     0.13
## edeq12       4 329 1.69 0.55   1.58    1.63 0.49 1.00 3.75  2.75 0.99     0.74
##             se
## covid_neg 0.04
## pswq      0.05
## iou       0.04
## edeq12    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$covid_neg)

hist(d2$pswq)

hist(d2$iou)

hist(d2$edeq12)

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

plot(d$covid_neg, d$iou)

plot(d$covid_neg, d$edeq12)

plot(d$pswq, d$iou)

plot(d$pswq, d$edeq12)

plot(d$iou, d$edeq12)

5 Check Your Assumptions

5.1 Pearson’s Correlation Coefficient Assumptions

  • Should have two measurements for each participant (can’t look at correlation with only one, should have no missing data)
  • Variables should be continuous and normally distributed (continuous = no categorical or ordinal variables- make note of any issues in write up)
  • Outliers should be identified and removed (they impact the validity of our test, can make misleading claims, looking for univariate variables based on z score - if above +3 or below -3 they are an outlier)
  • Relationship between the variables should be linear (have to transform variable, drop it, or use other statistical test if it is not, include in write up)

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$covid_neg <- scale(d2$covid_neg, center=T, scale=T)
hist(d2$covid_neg)

sum(d2$covid_neg < -3 | d2$covid_neg > 3)
## [1] 14
# This sum is counting any participants that are less than -3 or higher than +3

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

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

sum(d2$iou < -3 | d2$iou > 3)
## [1] 2
d2$edeq12 <- scale(d2$edeq12, center=T, scale=T)
hist(d2$edeq12)

sum(d2$edeq12 < -3 | d2$edeq12 > 3)
## [1] 2
# normally we would drop the participants that are outside of this range, but we are keeping them for the class.

5.2 Issues with My Data

My pswq variable met all of the assumptions of Pearson’s correlation coefficient. The others each fell short of the assumptions. Covid_neg, a measure of negative covid symptoms, had high kurtosis (17.21), high skew (4.16), and had 14 outliers. Iou, a measure of intolerance to uncertainty, and edeq12, a measure of disordered eating, had two outliers each. Outliers can distort the relationship between two variables and sway the correlation in their direction. Any correlations with these three variables should be evaluated carefully due to these risks.

6 Run a Single Correlation

corr_output <- corr.test(d2$pswq, d2$iou)

7 View Single Correlation

corr_output
## Call:corr.test(x = d2$pswq, y = d2$iou)
## Correlation matrix 
##      [,1]
## [1,]  0.6
## Sample Size 
## [1] 329
## 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
# The more tests we run, there is a greater chance of getting a false positive- to avoid, use anovas to control for family-wise error rate/risk of false positives. Need to adjust p value to make it more conservative if doing correlations. R automatically gives adjusted p value if we use a matrix instead of single correlation.

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 
##           covid_neg pswq  iou edeq12
## covid_neg      1.00 0.09 0.01   0.01
## pswq           0.09 1.00 0.60   0.22
## iou            0.01 0.60 1.00   0.34
## edeq12         0.01 0.22 0.34   1.00
## Sample Size 
## [1] 329
## Probability values (Entries above the diagonal are adjusted for multiple tests.) 
##           covid_neg pswq iou edeq12
## covid_neg      0.00 0.28   1      1
## pswq           0.09 0.00   0      0
## iou            0.85 0.00   0      0
## edeq12         0.88 0.00   0      0
## 
##  To see confidence intervals of the correlations, print with the short=FALSE option
# First set gives relationship between all of our pairs. Diagonal is the 1.00's that are correlation a variable with itself. Our variables are so correlated that the p values are all less than 0.001 still, but if we had less correlated p values, then the values above diagonal would be different than below because they are the adjusted ones. 
# Report adjusted p values from above the diagonal

10 Write Up Results

To test our hypothesis that stress negative covid symptoms, worry symptoms (measured by the pswq), intolerance of uncertainty (measured by the iou), and symptoms of disordered eating (measured by the edeq12) will all be correlated with each other and that worry symptoms will be higher in participants who are higher in intolerance of uncertainty or who report more symptoms of disordered eating. We calculated a series of Pearson’s correlation coefficients. Our data met most the assumptions of the test, with all variables aside from covid_neg meeting the standards of normality. Covid_neg had 14 outliers, iou and edeq12 had 2 outliers each, and pswq had no outliers. Any significant results involving the variables with outliers should be evaluated carefully, and covid_neg should be evaluated especially careful.

We did not find that all four variables were significantly correlated as predicted. Covid_neg did not have a significant correlation with any of the other variables, as there was a trivial effect size with each result and p values greater than 0.05. However, iou had a significant strong correlation to pswq (rs = 0.60; Cohen, 1988), edeq12 had a moderate correlation to iou (rs = 0.34; Cohen, 1988), and pswq had a weak correlation to edeq12 (rs = 0.22; Cohen, 1988). These p values were all less than 0.001. This test supported our second hypothesis, that worry would be higher in participants who are higher in intolerance to uncertainty or who report more symptoms of disordered eating, although the disordered eating relationship was weak. These relationships 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
Negative Covid Symptoms -0.00 1.00
Worry Symptoms (pswq) -0.00 1.00 .09
[-.02, .20]
Inolerance to Uncertainty (iou) 0.00 1.00 .01 .60**
[-.10, .12] [.53, .67]
Disordered Eating Symptoms (edeq12) 0.00 1.00 .01 .22** .34**
[-.10, .12] [.12, .32] [.24, .43]
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.