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

d <- read.csv(file="Data/mydata.csv", header=T)

3 State Your Hypothesis

We predict that markers of adulthood, inventory of the dimensions of emerging adulthood (IDEA), self-efficacy, and stress will all be correlated with each other. Furthermore, we predict that self-efficacy will be lower in participants who report lower markers of adulthood or who report higher levels of stress.

4 Check Your Variables

str(d)
## 'data.frame':    3084 obs. of  6 variables:
##  $ gender  : chr  "f" "m" "m" "f" ...
##  $ income  : chr  "1 low" "1 low" "rather not say" "rather not say" ...
##  $ moa_role: num  3 2.67 2.5 2 2.67 ...
##  $ idea    : num  3.75 3.88 3.75 3.75 3.5 ...
##  $ efficacy: num  3.4 3.4 2.2 2.8 3 2.4 2.3 3 3 3.7 ...
##  $ stress  : num  3.3 3.3 4 3.2 3.1 3.5 3.3 2.4 2.9 2.7 ...
d2 <- subset(d, select=c(moa_role,idea,efficacy,stress))
describe(d2)
##          vars    n mean   sd median trimmed  mad min max range  skew kurtosis
## moa_role    1 3084 2.97 0.72   3.00    3.00 0.74 1.0 4.0   3.0 -0.33    -0.84
## idea        2 3084 3.58 0.38   3.62    3.62 0.37 1.0 4.0   3.0 -1.54     4.47
## efficacy    3 3084 3.13 0.45   3.10    3.13 0.44 1.1 4.0   2.9 -0.25     0.46
## stress      4 3084 3.05 0.60   3.00    3.05 0.59 1.3 4.7   3.4  0.04    -0.17
##            se
## moa_role 0.01
## idea     0.01
## efficacy 0.01
## stress   0.01
# also use histograms to examine your continuous variables
hist(d2$moa_role)

hist(d2$idea)

hist(d2$efficacy)

hist(d2$stress)

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

plot(d2$moa_role, d2$efficacy)

plot(d2$moa_role, d2$stress)

plot(d2$idea, d2$efficacy)

plot(d2$idea, d2$stress)

plot(d2$efficacy, d2$stress)

4.1 Pearson’s Correlation Coefficient Assumptions

  • Should have two measurements for each participant
  • Variables should be continuous and normally distributed
  • Outliers should be identified and removed
  • Relationship between the variables should be linear

4.1.1 Checking for Outliers

d2$moa_role <- scale(d2$moa_role, center=T, scale=T)
hist(d2$moa_role)

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

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

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

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

4.2 Issues with My Data

None of my variables meet all of the assumptions of Pearson’s correlation coefficient. The IDEA variable had a high kurtosis of 4.47 and had 34 outliers. The efficacy variable did not reflect a normal distribution and had 15 outliers. Outliers can distort the relationship between two variables and sway the correlation in their direction. All 4 of the variables also appear to have non-linear relationships with all of the other variables. Pearson’s r may underestimate the strength of a non-linear relationship and distort the relationship direction. Any correlations with these variables should be evaluated carefully due to these risks.

5 Run a Single Correlation

corr_output <- corr.test(d2$moa_role, d2$efficacy)

6 View Single Correlation

corr_output
## Call:corr.test(x = d2$moa_role, y = d2$efficacy)
## Correlation matrix 
##      [,1]
## [1,] 0.11
## Sample Size 
## [1] 3084
## 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

7 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)

8 View Test Output

corr_output_m
## Call:corr.test(x = d2)
## Correlation matrix 
##          moa_role idea efficacy stress
## moa_role     1.00 0.07     0.11  -0.05
## idea         0.07 1.00     0.03   0.17
## efficacy     0.11 0.03     1.00  -0.41
## stress      -0.05 0.17    -0.41   1.00
## Sample Size 
## [1] 3084
## Probability values (Entries above the diagonal are adjusted for multiple tests.) 
##          moa_role idea efficacy stress
## moa_role     0.00 0.00     0.00   0.02
## idea         0.00 0.00     0.08   0.00
## efficacy     0.00 0.08     0.00   0.00
## stress       0.01 0.00     0.00   0.00
## 
##  To see confidence intervals of the correlations, print with the short=FALSE option

9 Write Up Results

To test our hypothesis that markers of adulthood, inventory of the dimensions of emerging adulthood (IDEA), self-efficacy, and stress would be correlated with one another, we calculated a series of Pearson’s correlation coefficients. None of our data met the assumptions of the test. Two variables, IDEA and efficacy, did have outliers and all variables appeared to have non-linear relationships with all of the other variables, and so any significant results involving these variables should be evaluated carefully.

As predicted, we found that most of our variables were significantly correlated ( ps < .05), with the exception of efficacy and idea, which presented a p-value of .08. However, the effect sizes of all correlations were small/negligible (rs < .5; Cohen, 1988). This test failed to support our second hypothesis, that self-efficacy will be lower in participants who report lower markers of adulthood or who report higher levels of stress, 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
Markers of Adulthood -0.00 1.00
IDEA -0.00 1.00 .07**
[.03, .10]
Efficacy 0.00 1.00 .11** .03
[.08, .15] [-.00, .07]
Perceived stress 0.00 1.00 -.05* .17** -.41**
[-.08, -.01] [.13, .20] [-.44, -.38]
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.