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 stress levels (measured by a stress scale), racial identity (measured by race_rc), age, sense of belonging (measured by belong), narcissistic personality traits (measured by npi), and exploitative tendencies (measured by exploit) will all be correlated with each other.

We predict that individuals experiencing higher levels of stress may exhibit higher levels of narcissistic traits and exploitative tendencies. Additionally, we hypothesize that individuals reporting a stronger sense of belonging may experience lower levels of stress and, consequently, lower levels of narcissistic traits and exploitative tendencies.We anticipate that certain racial identities may correlate with specific patterns of stress, narcissistic traits, and exploitative tendencies, necessitating further exploration to elucidate these potential relationships fully. # 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':    2152 obs. of  6 variables:
##  $ race_rc: chr  "white" "white" "white" "other" ...
##  $ age    : chr  "1 between 18 and 25" "1 between 18 and 25" "1 between 18 and 25" "1 between 18 and 25" ...
##  $ belong : num  2.8 4.2 3.6 4 3.4 4.2 3.9 3.6 2.9 2.5 ...
##  $ npi    : num  0.6923 0.1538 0.0769 0.0769 0.7692 ...
##  $ stress : num  3.3 3.3 4 3.2 3.1 3.5 3.3 2.4 2.9 2.7 ...
##  $ exploit: num  2 3.67 4.33 1.67 4 ...
# 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

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

# 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
## stress     1 2152 3.07 0.60   3.10    3.07 0.59 1.3 4.6   3.3 -0.02    -0.15
## belong     2 2152 3.21 0.61   3.20    3.23 0.59 1.3 5.0   3.7 -0.27    -0.10
## npi        3 2152 0.27 0.30   0.15    0.23 0.23 0.0 1.0   1.0  0.99    -0.56
## exploit    4 2152 2.37 1.38   2.00    2.18 1.48 1.0 7.0   6.0  0.96     0.38
##           se
## stress  0.01
## belong  0.01
## npi     0.01
## exploit 0.03
# 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$stress)

hist(d2$belong)

hist(d2$npi)

hist(d2$exploit)

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

plot(d2$stress,d2$npi)

plot(d2$stress,d2$explot)

plot(d2$belong,d2$npi)

plot(d2$belong,d2$exploit)

plot(d2$exploit,d2$npi)

4 Check Your Assumptions

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

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

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

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

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

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

4.2 Issues with My Data

The “exploit” variable’s high kurtosis (3.75) and 31 outliers suggest potential non-normality and skewness in its distribution. Outliers have the potential to distort the correlation between variables, potentially influencing the direction and strength of the relationships.

Given the observed non-linear relationships between the “exploit” variable and other variables, Pearson’s correlation coefficient may underestimate the strength of the relationship and misinterpret the direction of association. Therefore, any correlations involving the “exploit” variable should be interpreted cautiously, considering the risks associated with outliers and non-linear relationships.

In summary, while the other variables in the dataset meet the assumptions of Pearson’s correlation coefficient, correlations involving the “exploit” variable should be carefully evaluated due to its non-normal distribution, presence of outliers, and potential non-linear relationships with other variables. # Run a Single Correlation

corr_output <- corr.test(d2$stress, d2$belong)

5 View Single Correlation

corr_output
## Call:corr.test(x = d2$stress, y = d2$belong)
## Correlation matrix 
##      [,1]
## [1,] 0.29
## Sample Size 
## [1] 2152
## 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

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

7 View Test Output

corr_output_m
## Call:corr.test(x = d2)
## Correlation matrix 
##         stress belong   npi exploit
## stress    1.00   0.29 -0.05    0.04
## belong    0.29   1.00 -0.06   -0.05
## npi      -0.05  -0.06  1.00    0.35
## exploit   0.04  -0.05  0.35    1.00
## Sample Size 
## [1] 2152
## Probability values (Entries above the diagonal are adjusted for multiple tests.) 
##         stress belong  npi exploit
## stress    0.00   0.00 0.06    0.09
## belong    0.00   0.00 0.03    0.04
## npi       0.03   0.01 0.00    0.00
## exploit   0.09   0.01 0.00    0.00
## 
##  To see confidence intervals of the correlations, print with the short=FALSE option

8 Write Up Results

We conducted Pearson’s correlation coefficient analyses to explore the relationships between stress levels, racial identity, age, sense of belonging, narcissistic personality traits, and exploitative tendencies. While most variables adhered to test assumptions, the variable representing exploitative tendencies had outliers and non-linear relationships. Significant correlations were found among the variables (all p < .05), with substantial effect sizes (r > .5; Cohen, 1988). Notably, associations involving exploitative tendencies should be interpreted cautiously due to these issues. The findings support our hypothesis regarding the influence of stress on narcissistic traits and exploitative tendencies, as well as the potential role of belongingness in mitigating these effects. Further research should explore these relationships in depth, considering cultural and contextual factors.
Table 1: Means, standard deviations, and correlations with confidence intervals
Variable M SD 1 2 3
Stress scale (Stress) 0.00 1.00
sense of belonging (belong) -0.00 1.00 .29**
[.25, .33]
narcissistic personality traits (npi) -0.00 1.00 -.05* -.06**
[-.09, -.00] [-.10, -.02]
exploitative tendencies (exploit) 0.00 1.00 .04 -.05* .35**
[-.01, .08] [-.09, -.01] [.32, .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.