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 independence (measured by the MoA- Importance scale), role transitions (measured by the MoA- Importance scale), mindfulness (measured by the MAAS), and Self-efficacy (measured by the GSE scale) will all be correlated to each other. Furthermore, I predict that participants who report higher self-efficacy scores will also report higher independence and mindfulness scores.

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':    3045 obs. of  6 variables:
##  $ edu             : chr  "2 Currently in college" "5 Completed Bachelors Degree" "2 Currently in college" "2 Currently in college" ...
##  $ marriage5       : chr  "are currently divorced from one another" "are currently married to one another" "are currently married to one another" "are currently married to one another" ...
##  $ moa_independence: num  3.67 3.67 3.5 3 3.83 ...
##  $ moa_role        : num  3 2.67 2.5 2 2.67 ...
##  $ 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 ...
# 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(moa_independence, moa_role, mindful, efficacy))

# 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
## moa_independence    1 3045 3.54 0.46   3.67    3.61 0.49 1.00   4  3.00 -1.43
## moa_role            2 3045 2.97 0.72   3.00    3.00 0.74 1.00   4  3.00 -0.33
## mindful             3 3045 3.71 0.84   3.73    3.71 0.79 1.13   6  4.87 -0.07
## efficacy            4 3045 3.12 0.45   3.10    3.13 0.44 1.10   4  2.90 -0.25
##                  kurtosis   se
## moa_independence     2.47 0.01
## moa_role            -0.84 0.01
## mindful             -0.14 0.02
## efficacy             0.48 0.01
# also use histograms to examine your continuous variables
hist(d2$moa_independence)

hist(d2$moa_role)

hist(d2$mindful)

hist(d2$efficacy)

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

plot(d2$moa_independence, d$mindful)

plot(d2$moa_independence, d$efficacy)

plot(d2$moa_role, d$mindful)

plot(d2$moa_role, d$efficacy)

plot(d2$mindful, d$efficacy)

5 Check Your Assumptions

5.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

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.

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

sum(d2$moa_independence < -3 | d2$moa_independence > 3)
## [1] 49
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$mindful <- scale(d2$mindful, center=T, scale=T)
hist(d2$mindful)

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

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

5.2 Issues with My Data

Only the measure of role transitions meet all of the assumptions of Pearson’s correlation coefficient. The measure of independence had 49 outliers, the measure of mindfulness had 2 outliers, and the measure of self-efficacy had 16 outliers. Outliers can distort the relationship between two variables and sway the correlation in their direction. Additionally, the measure of independence had high kurtosis (2.47), but the skew and kurtosis for the other variables were within -2 and +2. All of the variables appear to have non-linear relationships with each other, with the exception of independence and role transitions. Pearson’s r may underestimate the strength of a non-linear relationship and distort the relationship direction. The correlations between all variables should be evaluated carefully to account for these risks.

6 Run a Single Correlation

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

7 View Single Correlation

corr_output
## Call:corr.test(x = d2$moa_independence, y = d2$moa_role)
## Correlation matrix 
##      [,1]
## [1,] 0.65
## Sample Size 
## [1] 3045
## 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 
##                  moa_independence moa_role mindful efficacy
## moa_independence             1.00     0.65    0.02     0.11
## moa_role                     0.65     1.00    0.06     0.11
## mindful                      0.02     0.06    1.00     0.25
## efficacy                     0.11     0.11    0.25     1.00
## Sample Size 
## [1] 3045
## Probability values (Entries above the diagonal are adjusted for multiple tests.) 
##                  moa_independence moa_role mindful efficacy
## moa_independence             0.00        0    0.32        0
## moa_role                     0.00        0    0.00        0
## mindful                      0.32        0    0.00        0
## efficacy                     0.00        0    0.00        0
## 
##  To see confidence intervals of the correlations, print with the short=FALSE option

10 Write Up Results

To test my hypothesis that independence (measured by the MoA- Importance scale), role transitions (measured by the MoA- Importance scale), mindfulness (measured by the MAAS), and self-efficacy (measured by the GSE scale) would be correlated with one another, I calculated a series of Pearson’s correlation coefficients. Only the measure of role transitions met the assumptions of the test because there were no outliers and the standards of normality were met. The other variables did not meet all the assumptions of the test and had outliers. Only the correlation between independence and role transitions was linear, all other correlations appeared non-linear. Any significant results involving any variable aside from role transitions should be evaluated carefully because the relationships were non-linear and all but one variable had outliers.

As predicted, I found that the variables were significantly correlated (all ps < .001), aside from the correlation between mindfulness and independence (p = .32). The effect size of only the correlation between independence and role transitions was large (r = 0.65; Cohen, 1988). The effect sizes of the correlations between independence and self-efficacy, role transitions and self-efficacy, and mindfulness and self-efficacy were weak (rs = .11, .11, .25, respectively; Cohen, 1988). The effect sizes for the correlations between independence and mindfulness and role transitions and mindfulness were trivial (rs < .09; Cohen, 1988) This test also weakly supported my second hypothesis that participants who report higher self-efficacy scores will also report higher independence and mindfulness scores, as shown by the correlation coefficients reported in Table 1.

Table 1: Means, standard deviations, and correlations with confidence intervals
Variable M SD 1 2 3
Independence (MoA- importance) 0.00 1.00
Role transitions (MoA- importance) 0.00 1.00 .65**
[.62, .67]
Mindfulness (MAAS) 0.00 1.00 .02 .06**
[-.02, .05] [.02, .10]
Self-efficacy (GSE scale) -0.00 1.00 .11** .11** .25**
[.08, .15] [.08, .15] [.22, .29]
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.