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="HWData/updated_eammi2_data.csv", header=T)

3 State Your Hypothesis

I predict that satisfaction with life (measured by the Satisfaction with Life Scale), perceived social support (measured by the Multidimensional Scale of Perceived Social Support), general self-efficacy (measured by the General Self Efficacy Scale), and emerging adulthood (measured by the Inventory of the Dimensions of Emerging Adulthood) will all be correlated with each other. Furthermore, I predict that life satisfaction will be lower in participants who are lower in perceived social support.

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':    3141 obs. of  6 variables:
##  $ income  : chr  "1 low" "1 low" "rather not say" "rather not say" ...
##  $ usdream : chr  "american dream is important and achievable for me" "american dream is important and achievable for me" "american dream is not important and maybe not achievable for me" "american dream is not important and maybe not achievable for me" ...
##  $ idea    : num  3.75 3.88 3.75 3.75 3.5 ...
##  $ swb     : num  4.33 4.17 1.83 5.17 3.67 ...
##  $ efficacy: num  3.4 3.4 2.2 2.8 3 2.4 2.3 3 3 3.7 ...
##  $ support : num  6 6.75 5.17 5.58 6 ...
# 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(idea, swb, efficacy, support))

# 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 kurtosis
## idea        1 3141 3.57 0.38   3.62    3.62 0.37 1.0   4   3.0 -1.52     4.33
## swb         2 3141 4.48 1.32   4.67    4.53 1.48 1.0   7   6.0 -0.36    -0.45
## efficacy    3 3141 3.13 0.45   3.10    3.13 0.44 1.1   4   2.9 -0.24     0.44
## support     4 3141 5.54 1.13   5.75    5.66 0.99 0.0   7   7.0 -1.09     1.42
##            se
## idea     0.01
## swb      0.02
## efficacy 0.01
## support  0.02
# 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$idea)

hist(d2$swb)

hist(d2$efficacy)

hist(d2$support)

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

plot(d2$idea, d2$efficacy)

plot(d2$idea, d2$support)

plot(d2$swb, d2$efficacy)

plot(d2$swb, d2$support)

plot(d2$efficacy, d2$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$idea_std <- scale(d$idea, center=T, scale=T)
hist(d$idea_std)

sum(d$idea_std < -3 | d$idea_std > 3)
## [1] 36
d$swb_std <- scale(d$swb, center=T, scale=T)
hist(d$swb_std)

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

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

sum(d$support_std < -3 | d$support_std > 3)
## [1] 42

5.2 Issues with My Data

Only one of my variables meet all of the assumptions of Pearson’s correlation coefficient. My inventory of the dimensions of emerging adulthood variable (idea) high a high kurtosis at 4.33, as well as 36 outliers. My general self-efficacy scale variable (efficacy) had 15 outliers. My scale of perceived social support variable (support) had 42 outliers. Outliers can distort the relationship between two variables and sway the correlation in their direction.

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 
##           idea   swb efficacy support
## idea      1.00 -0.01     0.03    0.12
## swb      -0.01  1.00     0.40    0.47
## efficacy  0.03  0.40     1.00    0.21
## support   0.12  0.47     0.21    1.00
## Sample Size 
## [1] 3141
## Probability values (Entries above the diagonal are adjusted for multiple tests.) 
##          idea  swb efficacy support
## idea     0.00 0.66     0.13       0
## swb      0.66 0.00     0.00       0
## efficacy 0.06 0.00     0.00       0
## support  0.00 0.00     0.00       0
## 
##  To see confidence intervals of the correlations, print with the short=FALSE option

8 Write Up Results

To test our hypothesis that satisfaction with life (measured by the satisfaction with life scale), perceived social support (measured by the Multidimensional Scale of Perceived Social Support), general self-efficacy (measured by the General Self Efficacy Scale), and emerging adulthood (measured by the Inventory of the Dimensions of Emerging Adulthood) would all be correlated with each other, and that life satisfaction and perceived social support are positively correlated, I calculated a series of Pearson’s correlation coefficients. Only one variable of the data met the assumptions of the test, with emerging adulthood having high kurtosis and many outliers, as well as self-efficacy and perceived social support having outliers. Any significant results involving these variables should be evaluated carefully.

My 1st hypotheses, that all of these variables were significantly correlated (all ps < .001), was not fully supported. Emerging adulthood was significantly correlated with perceived social support with an r of 0.12, showing a weak correlation. It was not significantly correlated with other variables, which does not support my first hypothesis.

Satisfaction with life was significantly correlated with self-efficacy with an r of 0.4, showing a moderate association and supporting my first hypothesis.

Self efficacy was significantly correlated with perceived social support with an r of 0.21, a weak association that supports my first hypothesis.

Satisfaction with life was significantly correlated with perceived social support with an r of 0.47,a moderate association that supports my first hypothesis. As well, it supports my second hypothesis, that life satisfaction and perceived social support are positively correlated.

Table 1: Means, standard deviations, and correlations with confidence intervals
Variable M SD 1 2 3
Inventory of the Dimensions of Emerging Adulthood (IDEA) 3.57 0.38
Satisfaction with Life Scale (SWB) 4.48 1.32 -.01
[-.04, .03]
General Self Efficacy Scale (Efficacy) 3.13 0.45 .03 .40**
[-.00, .07] [.37, .43]
Multidimensional Scale of Perceived Social Support (Support) 5.54 1.13 .12** .47** .21**
[.09, .15] [.44, .50] [.17, .24]
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.