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

I predict that those who report higher levels of isolation (measured by UCLA loneliness scale) also report lower levels of support (measured by social support measure) , as well as those with reported weaker mental flexibility (measured through mental flexibility questionnaire) showed increase worrying (measured by Penn State worry questionaire) during the pandemic. .

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':    1211 obs. of  8 variables:
##  $ sexual_orientation: chr  "Heterosexual/Straight" "Heterosexual/Straight" "Heterosexual/Straight" "Heterosexual/Straight" ...
##  $ mhealth           : chr  "none or NA" "anxiety disorder" "none or NA" "none or NA" ...
##  $ isolation         : num  2.25 3.5 1 2.5 1.75 2 1.25 1 3 1.25 ...
##  $ support           : num  2.5 2.17 5 2.5 3.67 ...
##  $ mfq_26            : num  4.2 3.35 4.65 4.65 4.5 4.3 5.25 4.45 5 4.7 ...
##  $ pswq_std          : num  2.309 0.851 -1.124 1.163 -0.342 ...
##  $ variable2         : chr  "Heterosexual/Straight" "Heterosexual/Straight" "Heterosexual/Straight" "Heterosexual/Straight" ...
##  $ variable3         : chr  "none or NA" "anxiety disorder" "none or NA" "none or NA" ...
# 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(isolation,support,mfq_26,pswq_std))

# 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
## isolation    1 1211  2.15 0.84   2.00    2.12 1.11  1.00 3.50  2.50  0.17
## support      2 1211  3.56 0.95   3.67    3.62 0.99  1.00 5.00  4.00 -0.44
## mfq_26       3 1211  4.31 0.67   4.35    4.32 0.67  1.80 6.00  4.20 -0.33
## pswq_std     4 1211 -0.04 1.00   0.00   -0.03 1.15 -2.25 2.31  4.56 -0.07
##           kurtosis   se
## isolation    -1.28 0.02
## support      -0.52 0.03
## mfq_26        0.16 0.02
## pswq_std     -0.95 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$isolation)

hist(d2$support)

hist(d2$mfq_26)

hist(d2$pswq_std)

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

plot(d$isolation, d$mfq_26)

plot(d2$isolation, d2$pswq_std)

plot(d2$support, d2$mfq_26)

plot(d2$support, d2$pswq_std)

plot(d2$mfq_26, d2$pswq_std)

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

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

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

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

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

5.2 Issues with My Data

All of my variables met the assumptions for Pearson’s correlation coefficient. All of my variables had no outliers except mental flexibility which had 4 outliers. Mental flexibility (mfq_26) also had the highest amount of kurtosis compared to the other variables which was (0.16). # 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 
##           isolation support mfq_26 pswq_std
## isolation      1.00   -0.63  -0.40     0.46
## support       -0.63    1.00   0.40    -0.32
## mfq_26        -0.40    0.40   1.00    -0.48
## pswq_std       0.46   -0.32  -0.48     1.00
## Sample Size 
## [1] 1211
## Probability values (Entries above the diagonal are adjusted for multiple tests.) 
##           isolation support mfq_26 pswq_std
## isolation         0       0      0        0
## support           0       0      0        0
## mfq_26            0       0      0        0
## pswq_std          0       0      0        0
## 
##  To see confidence intervals of the correlations, print with the short=FALSE option

7 Write Up Results

During the pandemic we used a correlation matrix to see how those who report higher levels of isolation (measured by UCLA loneliness scale) also report lower levels of support (measured by social support measure) , as well as those with reported weaker mental flexibility (measured through mental flexibility questionnaire) showed increase worrying (measured by Penn State worry questionnaire) during the pandemic. Most of our data met the assumptions of the test, with all variables meeting the standards of normality with only mental flexibility having 4 outliers. All of the variables were uni modal and normal except for the variable isolation.

As predicted, we found that all of the variables but isolation were significantly correlated (all ps < .001). The effect sizes of all correlations were large (rs > .5; Cohen, 1988). This test showed that isolation and support were correlated negatively (-.63) and the correlation between mental flexibility and worrying was negatively correlated (-.48). With all of my p values being zero it shows that the data is significant and is reported as less than .001.

Table 1: Means, standard deviations, and correlations with confidence intervals
Variable M SD 1 2 3
Isolation (isolation) 2.15 0.84
Support (support) 3.56 0.95 -.63**
[-.66, -.59]
Mental flexibility questionnaire (mfq_26) 4.31 0.67 -.40** .40**
[-.44, -.35] [.35, .44]
Penn State Worry questionnaire (pswq_std) -0.04 1.00 .46** -.32** -.48**
[.41, .50] [-.37, -.27] [-.52, -.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.