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

3 State Your Hypothesis

I predict that satisfaction with life (measured by the Satisfaction with Life Scale), Narcissism (measured by the NPI), exploitativeness (measured by the Interpersonal Exploitativeness Scale), and stress (measured by the Percieved Stress Questionnaire) will all be correlated with each other. # you can write: they will be correlated with each other, you can specify directionality for hypothesis. Use all 4 of your continuous variables in your hypothesis. # 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':    3155 obs. of  7 variables:
##  $ ResponseId: chr  "R_BJN3bQqi1zUMid3" "R_2TGbiBXmAtxywsD" "R_12G7bIqN2wB2N65" "R_39pldNoon8CePfP" ...
##  $ gender    : chr  "f" "m" "m" "f" ...
##  $ race_rc   : chr  "white" "white" "white" "other" ...
##  $ swb       : num  4.33 4.17 1.83 5.17 3.67 ...
##  $ npi       : num  0.6923 0.1538 0.0769 0.0769 0.7692 ...
##  $ exploit   : num  2 3.67 4.33 1.67 4 ...
##  $ stress    : num  3.3 3.3 4 3.2 3.1 3.5 3.3 2.4 2.9 2.7 ...
# we're going to create a fake variable for this lab, so that it has four variables and mirrors the homework assignment. SKIP THIS STEP FOR THE HOMEWORK
# delete this on the homework.Delete the fake

# 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(swb, stress, exploit, npi))

# 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
## swb        1 3155 4.48 1.32   4.67    4.53 1.48 1.0 7.0   6.0 -0.36    -0.46
## stress     2 3155 3.05 0.60   3.00    3.05 0.59 1.3 4.7   3.4  0.03    -0.17
## exploit    3 3155 2.38 1.37   2.00    2.20 1.48 1.0 7.0   6.0  0.95     0.36
## npi        4 3155 0.28 0.31   0.15    0.24 0.23 0.0 1.0   1.0  0.94    -0.69
##           se
## swb     0.02
## stress  0.01
## exploit 0.02
## npi     0.01
# 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$swb)

hist(d2$npi)

hist(d2$exploit)

hist(d2$stress)

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

plot(d2$swb, d2$exploit)

plot(d2$swb, d2$stress)

plot(d2$npi, d2$exploit)

plot(d2$npi, d2$stress)

plot(d2$exploit, d2$stress)

4 Check Your Assumptions

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

4.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$swb_std <- scale(d2$swb, center=T, scale=T)
hist(d$swb_std)

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

sum(d$npi_std < -3 | d$npi_std > 3)
## [1] 0
d$exploit_std <- scale(d2$exploit, center=T, scale=T)
hist(d$exploit_std)

sum(d$exploit_std < -3 | d$exploit_std > 3)
## [1] 33
d$stress_std <- scale(d2$stress, center=T, scale=T)
hist(d$stress_std)

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

4.2 Issues with My Data

All but one of my variables meet all of the assumptions of Pearson’s correlation coefficient. One variable, my exploit had 33 outliers. Outliers can distort the relationship between two variables and sway the correlation in their direction.

5 Create a Correlation Matrix

corr_output_m <- corr.test(d2)
#Effect size (r) cutoffs: <.1=trivial; <.3=small; <.5=medium; >.5= large

6 View Test Output

corr_output_m
## Call:corr.test(x = d2)
## Correlation matrix 
##           swb stress exploit   npi
## swb      1.00  -0.50   -0.08  0.03
## stress  -0.50   1.00    0.03 -0.06
## exploit -0.08   0.03    1.00  0.36
## npi      0.03  -0.06    0.36  1.00
## Sample Size 
## [1] 3155
## Probability values (Entries above the diagonal are adjusted for multiple tests.) 
##          swb stress exploit  npi
## swb     0.00   0.00    0.00 0.12
## stress  0.00   0.00    0.12 0.00
## exploit 0.00   0.06    0.00 0.00
## npi     0.06   0.00    0.00 0.00
## 
##  To see confidence intervals of the correlations, print with the short=FALSE option
# write for probability values that it is less than .001, all p-values

7 Write Up Results

To test our hypothesis that satisfaction with life (measured by the Satisfaction with Life Scale), Narcissism (measured by the NPI), exploitativeness (measured by the Interpersonal Exploitativeness Scale), and stress (measured by the Percieved Stress Questionnaire) 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 however, one variable had 33 outliers and so any significant results involving that variable should be evaluated carefully.

As predicted, we found that a couple variables were significantly correlated which were swb and stress, swb and exploit, stress and npi, exploit and npi (all ps < .001). However, swb and npi and stress and exploit were not statistically significant (p=.12) As well as npi and swb (p=.06). The effect sizes swb and stress is medium (rs > .5). The effect size of swb and exploit is trivial (rs<.1).The effect size of stress and npi is trivial (rs<.1). The effect size of exploit and npi is small (rs>.3).

Table 1: Means, standard deviations, and correlations with confidence intervals
Variable M SD 1 2 3
Satisfaction with Life Scale (SWB 4.48 1.32
Narcissistic Personality Inventory (NPI) 3.05 0.60 -.50**
[-.53, -.48]
Interpersonal Exploitativeness Scale (Exploit) 2.38 1.37 -.08** .03
[-.11, -.04] [-.00, .07]
Percieved Stress Questionnaire (PHQ) 0.28 0.31 .03 -.06** .36**
[-.00, .07] [-.10, -.03] [.33, .39]
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.