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

3 State Your Hypothesis

We predict that Worryness (measured by the PSWQ), Mental Flexibility (measured by the MFQ), Eating Disorders (measured by the EDEQ), and Depression (measured by the PHQ) will all be correlated with each other.

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':    303 obs. of  6 variables:
##  $ income      : chr  "3 high" "2 middle" "2 middle" "2 middle" ...
##  $ exercise_cat: chr  "1 less than 1 hour" "2 1-2 hours" "2 1-2 hours" "2 1-2 hours" ...
##  $ pswq_std    : num  2.309 1.163 -0.342 -0.127 0.661 ...
##  $ mfq_26      : num  4.2 4.65 4.5 5.25 4.05 4.25 4.4 4.75 4.4 5.3 ...
##  $ edeq12      : num  1.58 1.67 1.42 3.17 1.58 ...
##  $ phq         : num  1.33 2.33 1.11 2.33 1.56 ...
# 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(pswq_std,phq,mfq_26,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
## pswq_std    1 303 -0.08 1.01  -0.13   -0.11 1.17 -2.06 2.31  4.37  0.24
## phq         2 303  1.49 0.54   1.33    1.39 0.33  1.00 3.78  2.78  1.87
## mfq_26      3 303  4.55 0.59   4.60    4.58 0.52  2.40 5.95  3.55 -0.45
## edeq12      4 303  1.68 0.54   1.58    1.62 0.49  1.00 3.75  2.75  0.99
##          kurtosis   se
## pswq_std    -0.77 0.06
## phq          3.74 0.03
## mfq_26       0.40 0.03
## edeq12       0.77 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$pswq_std)

hist(d2$phq)

hist(d2$mfq_26)

hist(d2$edeq12)

# last, use scatterplots to examine your continuous variables together
plot(d2$pswq_std, d$phq)

plot(d2$pswq_std, d$mfq_26)

plot(d2$pswq_std, d$edeq12)

plot(d2$phq, d2$mfq_26)

plot(d2$phq, d2$edeq12)

plot(d2$mfq_26, d2$edeq12)

5 Check Your Assumptions

5.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.

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.

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

sum(d$pswq_std < -3 | d$pswq_std > 3)
## [1] 0
d$phq_std <- scale(d$phq, center=T, scale=T)
hist(d$phq_std)

sum(d$phq_std < -3 | d$phq_std > 3)
## [1] 9
d$mfq_std <- scale(d$mfq_26, center=T, scale=T)
hist(d$mfq_std)

sum(d$mfq_std < -3 | d$mfq_std > 3)
## [1] 1
d$edeq_std <- scale(d$edeq12, center=T, scale=T)
hist(d$edeq_std)

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

5.2 Issues with My Data

All but one of my variables meet all of the assumptions of Pearson’s correlation coefficient. One variable, phq which measures depression levels had high kurtosis (3.74) and had 9 outliers. In my other variables, I had 1 outlier in my mfq and 3 outliers in my edeq. Outliers can distort the relationship between two variables and sway the correlation in their direction. Pearson’s r may underestimate the strength of a non-linear relationship and distort the relationship direction. # Create a Correlation Matrix

corr_output_m <- corr.test(d2)

6 View Test Output

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

corr_output_m
## Call:corr.test(x = d2)
## Correlation matrix 
##          pswq_std   phq mfq_26 edeq12
## pswq_std     1.00  0.49  -0.50   0.24
## phq          0.49  1.00  -0.36   0.56
## mfq_26      -0.50 -0.36   1.00  -0.21
## edeq12       0.24  0.56  -0.21   1.00
## Sample Size 
## [1] 303
## Probability values (Entries above the diagonal are adjusted for multiple tests.) 
##          pswq_std phq mfq_26 edeq12
## pswq_std        0   0      0      0
## phq             0   0      0      0
## mfq_26          0   0      0      0
## edeq12          0   0      0      0
## 
##  To see confidence intervals of the correlations, print with the short=FALSE option

7 Write Up Results

To test our hypothesis that Worryness (measured by the PSWQ_STD), depression symptoms (measured by the PHQ-9), Mental Flexibility (measured by the mfq_26), and Eating Disorders (measured by edeq_12) 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 except for phq meeting the standards of normality. Phq, Edeq, and Mfq all had at least one outlier which was mentioned above.

As predicted, we found that all three variables were significantly correlated (all ps < .001). The effect sizes of all correlations were between small, medium and large with none of our variables being trivial(rs > .5; Cohen, 1988). Our strongest relationships were between Eating disorders and depression (.56) and depression and worryness (.49).

Table 1: Means, standard deviations, and correlations with confidence intervals
Variable M SD 1 2 3
Worryness (PSWQ) -0.08 1.01
Depression symptoms (PHQ-9) 1.49 0.54 .49**
[.40, .57]
Mental Flexibility (MFQ-26) 4.55 0.59 -.50** -.36**
[-.58, -.41] [-.46, -.26]
Eating Disorders (EDEQ-12) 1.68 0.54 .24** .56** -.21**
[.13, .34] [.48, .63] [-.32, -.10]
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.