1 Loading Libraries

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

3 State Your Hypothesis

I predict that mindfulness (measured by the MAAS), efficacy (measured by the GSE), support (measured by the MSPSS), and stress (measured by PSQ) will all be correlated with each other. Furthermore, I predict that stress will be lower in participants who are higher in mindfulness, efficacy, and support.

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':    3161 obs. of  7 variables:
##  $ ResponseId: chr  "R_BJN3bQqi1zUMid3" "R_2TGbiBXmAtxywsD" "R_12G7bIqN2wB2N65" "R_39pldNoon8CePfP" ...
##  $ gender    : chr  "f" "m" "m" "f" ...
##  $ sibling   : chr  "at least one sibling" "at least one sibling" "at least one sibling" "at least one sibling" ...
##  $ mindful   : num  2.4 1.8 2.2 2.2 3.2 ...
##  $ efficacy  : num  3.4 3.4 2.2 2.8 3 2.4 2.3 3 3 3.7 ...
##  $ support   : num  6 6.75 5.17 5.58 6 ...
##  $ stress    : num  3.3 3.3 4 3.2 3.1 3.5 3.3 2.4 2.9 2.7 ...
# 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(mindful,efficacy,support,stress))

# 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
## mindful     1 3161 3.71 0.84   3.73    3.71 0.79 1.13 6.0  4.87 -0.06    -0.14
## efficacy    2 3161 3.13 0.45   3.10    3.13 0.44 1.10 4.0  2.90 -0.26     0.53
## support     3 3161 5.53 1.13   5.75    5.65 0.99 0.00 7.0  7.00 -1.11     1.49
## stress      4 3161 3.05 0.60   3.00    3.05 0.59 1.30 4.7  3.40  0.04    -0.17
##            se
## mindful  0.01
## efficacy 0.01
## support  0.02
## stress   0.01
# also use histograms to examine your continuous variables
hist(d2$mindful)

hist(d2$efficacy)

hist(d2$support)

hist(d2$stress)

# last, use scatterplots to examine your continuous variables together
plot(d2$mindful, d2$efficacy)

plot(d2$mindful, d2$support)

plot(d2$mindful, d2$stress)

plot(d2$efficacy, d2$support)

plot(d2$efficacy, d2$stress)

plot(d2$support, d2$stress)

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$mindful_std <- scale(d$mindful, center=T, scale=T)
hist(d$mindful_std)

sum(d$mindful_std < -3 | d$mindful_std > 3)
## [1] 2
d$efficacy_std <- scale(d$efficacy, center=T, scale=T)
hist(d$efficacy_std)

sum(d$efficacy_std < -3 | d$efficacy_std > 3)
## [1] 17
d$support_std <- scale(d$support, center=T, scale=T)
hist(d$support_std)

sum(d$support_std < -3 | d$support_std > 3)
## [1] 46
d$stress_std <- scale(d$stress, center=T, scale=T)
hist(d$stress_std)

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

5.2 Issues with My Data

All of my variables meet all of the assumptions of Pearson’s correlation coefficient. There were a total of 65 outliers in my data with 46 coming from support, 17 coming from efficacy, and 2 coming from mindful 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.

6 Create a Correlation Matrix

corr_output_m <- corr.test(d2)

7 View Test Output

corr_output_m
## Call:corr.test(x = d2)
## Correlation matrix 
##          mindful efficacy support stress
## mindful     1.00     0.25    0.18  -0.40
## efficacy    0.25     1.00    0.20  -0.40
## support     0.18     0.20    1.00  -0.21
## stress     -0.40    -0.40   -0.21   1.00
## Sample Size 
## [1] 3161
## Probability values (Entries above the diagonal are adjusted for multiple tests.) 
##          mindful efficacy support stress
## mindful        0        0       0      0
## efficacy       0        0       0      0
## support        0        0       0      0
## stress         0        0       0      0
## 
##  To see confidence intervals of the correlations, print with the short=FALSE option

8 Write Up Results

To test my hypothesis that mindfulness (measured by the MAAS), efficacy (measured by the GSE), support (measured by the MSPSS), and stress (measured by PSQ) would be correlated with one another, I calculated a series of Pearson’s correlation coefficients. Most of my data met the assumptions of the test, with all variables meeting the standards of normality and no outliers. Three variables, mindful, efficacy, and support, did have outliers but their relationships with theh other variables were mostly linear relationships, and so any significant results involving these variables may be somewhat confounded by the outliers.

As predicted, I found that all four variables were significantly correlated (all ps < .001). The effect sizes of all correlations were small or negligible (rs < .5; Cohen, 1988). This test also supported my second hypothesis, that stress will be lower in participants who are higher in mindfulness, efficacy, and support, 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
Mindful (MAAS) 3.71 0.84
Efficacy (GSE) 3.13 0.45 .25**
[.22, .28]
Support (MSPSS) 5.53 1.13 .18** .20**
[.15, .22] [.17, .24]
Stress (PSQ) 3.05 0.60 -.40** -.40** -.21**
[-.43, -.37] [-.43, -.37] [-.24, -.18]
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.