1 Loading Libraries

library(psych) # for the describe() command and the corr.test() command
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/mydata.csv", header=T)

3 State Your Hypothesis

We predict that general anxiety (measured by the gad scale), isolation (measured by the UCLA loneliness scale), stress (measured by the pss), and School COVID support (a measure of support schools are offering to students during times of COVID-19) will all be correlated with each other. Furthermore, we predict that isolation will be lower in participants who are experiencing higher levels in stress or general anxiety.

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':    147 obs. of  7 variables:
##  $ X                   : int  7851 7856 7861 7862 7874 7875 7876 7880 7881 7884 ...
##  $ gender              : chr  "male" "male" "female" "female" ...
##  $ ethnicity           : chr  "White - British, Irish, other" "White - British, Irish, other" "White - British, Irish, other" "White - British, Irish, other" ...
##  $ gad                 : num  3.86 3.43 4 1.86 3.86 ...
##  $ isolation           : num  3.25 3.25 2.25 2 2.75 3.5 3.5 3 3.25 3 ...
##  $ pss                 : num  3.75 3.25 3.75 3.5 3.75 5 4 4.25 2.75 4.5 ...
##  $ school_covid_support: num  1.4 1.2 1 1.6 1.4 ...
# 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(gad,isolation,pss,school_covid_support))

# you can use the describe() command on an entire dataframe (d) or just on a single variable (d$gad)
describe(d2)
##                      vars   n mean   sd median trimmed  mad min max range  skew
## gad                     1 147 2.41 0.94   2.29    2.39 1.27   1 4.0   3.0  0.19
## isolation               2 147 2.39 0.76   2.50    2.41 1.11   1 3.5   2.5 -0.16
## pss                     3 147 3.31 0.91   3.50    3.31 1.11   1 5.0   4.0 -0.11
## school_covid_support    4 147 1.52 0.33   1.60    1.53 0.30   1 2.0   1.0 -0.14
##                      kurtosis   se
## gad                     -1.29 0.08
## isolation               -1.17 0.06
## pss                     -0.66 0.07
## school_covid_support    -1.17 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$gad)

hist(d2$isolation)

hist(d2$pss)

hist(d2$school_covid_support)

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

plot (d2$gad, d2$pss)

plot (d2$gad, d2$school_covid_support)

plot (d2$pss, d2$isolation)

plot (d2$pss, d2$school_covid_support)

plot (d2$isolation, d2$school_covid_support)

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

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

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

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

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

5.2 Issues with My Data

All of my variables meet all of the assumptions of Pearson’s correlation coefficient.

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 
##                        gad isolation   pss school_covid_support
## gad                   1.00      0.58  0.73                -0.29
## isolation             0.58      1.00  0.61                -0.19
## pss                   0.73      0.61  1.00                -0.28
## school_covid_support -0.29     -0.19 -0.28                 1.00
## Sample Size 
## [1] 147
## Probability values (Entries above the diagonal are adjusted for multiple tests.) 
##                      gad isolation pss school_covid_support
## gad                    0      0.00   0                 0.00
## isolation              0      0.00   0                 0.02
## pss                    0      0.00   0                 0.00
## school_covid_support   0      0.02   0                 0.00
## 
##  To see confidence intervals of the correlations, print with the short=FALSE option

8 Write Up Results

To test our hypothesis general anxiety (measured by the gad scale), isolation (measured by the UCLA loneliness scale), stress (measured by the pss scale), and School COVID support (a measure of support schools are offering to students during times of COVID-19) would be correlated with one another, we calculated a series of Pearson’s correlation coefficients. All of our data met the assumptions of the test, with all variables meeting the standards of normality and no outliers.

Although it was not predicted, we found little to no correlation or statistical significance between the four continuous variables (all p > .01). This test also was not able to supported our second hypothesis, that isolation would be lower in participants who are higher in stress or experience anxiety, 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
General Anxiety (gad) 2.41 0.94
Isolation (isolation) 2.39 0.76 .58**
[.46, .68]
Stress (pss) 3.31 0.91 .73** .61**
[.64, .80] [.50, .70]
School COVID Support (school_covid_support) 1.52 0.33 -.29** -.19* -.28**
[-.43, -.13] [-.34, -.03] [-.43, -.13]
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.