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 predict that Extroversion (measured by the BFI), Agreeableness (measured by the BFI), self-esteem (measured by the RSE-10), and Anxiety in relation to the Pandemic (measured by the PAS scale) will all be correlated with each other. Furthermore, we predict that self-esteem will be lower in participants who are higher in stress or who reported higher levels of 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':    1009 obs. of  6 variables:
##  $ trans    : chr  "no" "no" "no" "no" ...
##  $ age      : chr  "1 under 18" "1 under 18" "4 between 36 and 45" "4 between 36 and 45" ...
##  $ big5_agr : num  4.33 6.67 4.67 6.67 5.33 ...
##  $ big5_ext : num  1.67 6 5 5.67 4 ...
##  $ rse      : num  1.6 3.9 1.7 2.4 1.8 3.5 3 3.5 2.5 3.4 ...
##  $ pas_covid: num  4.56 3.33 4.22 3.56 4.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(big5_agr,big5_ext,rse,pas_covid))


describe(d2)
##           vars    n mean   sd median trimmed  mad min max range  skew kurtosis
## big5_agr     1 1009 5.01 1.12   5.00    5.05 0.99   1   7     6 -0.39    -0.03
## big5_ext     2 1009 4.34 1.45   4.33    4.38 1.48   1   7     6 -0.23    -0.77
## rse          3 1009 2.65 0.71   2.70    2.67 0.74   1   4     3 -0.20    -0.74
## pas_covid    4 1009 3.24 0.68   3.22    3.26 0.66   1   5     4 -0.23     0.12
##             se
## big5_agr  0.04
## big5_ext  0.05
## rse       0.02
## pas_covid 0.02
# Kurtosis is in acceptable ranges for all variables

# also use histograms to examine your continuous variables
hist(d2$big5_agr)

hist(d2$big5_ext)

hist(d2$rse)

hist(d2$pas_covid)

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

plot(d$big5_agr,d2$rse)

plot(d$big5_agr,d2$pas_covid)

plot(d2$big5_ext,d2$rse)

plot(d2$big5_ext,d2$pas_covid)

plot(d2$rse,d2$pas_covid)

5 Check Your Assumptions

5.1 Pearson’s Correlation Coefficient Assumptions

5.2 Should have two measurements for each participant

5.3 Variables should be continuous and normally distributed

5.4 Outliers should be identified and removed

5.5 Relationship between the variables should be linear

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

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

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

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

sum(d2$pas_covid < -3 | d2$pas_covid > 3)
## [1] 1

5.6 Issues with My Data

All but one of my variables meet all of the assumptions of Pearson’s correlation coefficient. All variables had kurtosis within the ideal range. Outliers can distort the relationship between two variables and sway the correlation in their direction. While the measure of agreeableness had 3 outliers and the measure for Anxiety had 1 outlier, we do not consider them statistically significant enough to effect our results.

6 Run a Single Correlation

corr_output <- corr.test(d2$rse,d2$pas_covid)

7 View Single Correlation

corr_output
## Call:corr.test(x = d2$rse, y = d2$pas_covid)
## Correlation matrix 
##      [,1]
## [1,] -0.3
## Sample Size 
## [1] 1009
## 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

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 
##           big5_agr big5_ext   rse pas_covid
## big5_agr      1.00     0.08  0.23      0.02
## big5_ext      0.08     1.00  0.38     -0.08
## rse           0.23     0.38  1.00     -0.30
## pas_covid     0.02    -0.08 -0.30      1.00
## Sample Size 
## [1] 1009
## Probability values (Entries above the diagonal are adjusted for multiple tests.) 
##           big5_agr big5_ext rse pas_covid
## big5_agr      0.00     0.03   0      0.50
## big5_ext      0.01     0.00   0      0.03
## rse           0.00     0.00   0      0.00
## pas_covid     0.50     0.01   0      0.00
## 
##  To see confidence intervals of the correlations, print with the short=FALSE option

10 Write Up Results

To test our hypothesis that Extroversion (measured by the BFI), Agreeableness (measured by the BFI), self-esteem (measured by the RSE-10), and Anxiety in relation to the Pandemic (measured by the PAS scale) will all be correlated with each other, we calculated a series of Pearson’s correlation coefficients. Most of our data met the assumptions of the test, with all variables meeting the standards of normality and minimal outliers. Two variables,agreeableness and anxiety, did have a small number of outliers but had linear relationships with the other variables.

Contrary to our prediction, we found that some of out variables were not significantly correlated with one another. We did see a moderate correlation between extraversion and self-esteem (.38) as well as a moderate negative correlation between self-esteem and anxiety. The effect sizes of all correlations were varied. This test also supported second hypothesis, that lower self-esteem would be reflected in a higher Anxiety rating during Covid, as is shown in the coefficients in table 1.

Table 1: Means, standard deviations, and correlations with confidence intervals
Variable M SD 1 2 3
Agreeableness (BFI) -0.00 1.00
Extraversion (BFI) -0.00 1.00 .08*
[.02, .14]
Self-esteem (RSE-10) -0.00 1.00 .23** .38**
[.17, .29] [.33, .43]
Pandemic Anxiety (PAS) 0.00 1.00 .02 -.08* -.30**
[-.04, .08] [-.14, -.02] [-.36, -.25]
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.