library(haven)

2a)

PSY772_ProblemSet3_Mediation <- read_sav("C:/Users/John Majoubi/Downloads/PSY772-ProblemSet3-Mediation.sav")
listwise.PS3.Q2 = na.exclude(PSY772_ProblemSet3_Mediation[c(3,7,8)])
listwise.PS3.Q2 = na.exclude(PSY772_ProblemSet3_Mediation[c(3,7,8)])
library(psych)
## Warning: package 'psych' was built under R version 4.2.3
str(listwise.PS3.Q2)
## tibble [221 × 3] (S3: tbl_df/tbl/data.frame)
##  $ Altruism_avg   : num [1:221] 6.3 4.9 6 6.2 5.2 4.6 5.6 4.8 4.5 5.4 ...
##   ..- attr(*, "label")= chr "Trait Altruism average score"
##   ..- attr(*, "format.spss")= chr "F8.2"
##   ..- attr(*, "display_width")= int 10
##  $ Diffusion_state: num [1:221] 3.38 2.62 3.75 0.25 2.62 ...
##   ..- attr(*, "label")= chr "State level diffusion of responsibility"
##   ..- attr(*, "format.spss")= chr "F8.2"
##   ..- attr(*, "display_width")= int 15
##  $ HelpBehave     : num [1:221] 4 3.6 3.2 2.9 4 3 3.3 3.5 2.4 3.8 ...
##   ..- attr(*, "label")= chr "Extent of Helping Behavior"
##   ..- attr(*, "format.spss")= chr "F8.2"
##   ..- attr(*, "display_width")= int 10
##  - attr(*, "na.action")= 'exclude' Named int [1:40] 2 6 7 9 10 11 25 39 40 41 ...
##   ..- attr(*, "names")= chr [1:40] "2" "6" "7" "9" ...
names(listwise.PS3.Q2)
## [1] "Altruism_avg"    "Diffusion_state" "HelpBehave"

2b) All values are in their respective ranges.

2c) Screening for outliers

summary(cooks.distance(lm(HelpBehave ~ Altruism_avg + Diffusion_state, data = listwise.PS3.Q2)))
##      Min.   1st Qu.    Median      Mean   3rd Qu.      Max. 
## 2.020e-06 6.635e-04 2.383e-03 4.479e-03 5.679e-03 5.598e-02

All values are under 1.00.

2d) There were zero outliers, so there was no need to delete cases

Assessing linearity of outcome prediction by mediator

cor(listwise.PS3.Q2)
##                 Altruism_avg Diffusion_state HelpBehave
## Altruism_avg       1.0000000       0.6025859  0.2582764
## Diffusion_state    0.6025859       1.0000000  0.4017595
## HelpBehave         0.2582764       0.4017595  1.0000000

2e) linearity of outcome prediction by mediator (b path) exists and so does the linearity of the mediator (a path) because r > .20.

2f)

plot(listwise.PS3.Q2)

#### There are no curvilinear relationships.

2g) assessing singularity

det(cor(listwise.PS3.Q2), use = "complete")
## [1] 0.5338275

There is no singularity. Determinant is greater than 0.

2h) All cruciaal assumptions are met.

2i)

mediate(HelpBehave ~ Altruism_avg + (Diffusion_state), data = listwise.PS3.Q2, n.iter = 5000)

## 
## Mediation/Moderation Analysis 
## Call: mediate(y = HelpBehave ~ Altruism_avg + (Diffusion_state), data = listwise.PS3.Q2, 
##     n.iter = 5000)
## 
## The DV (Y) was  HelpBehave . The IV (X) was  Altruism_avg . The mediating variable(s) =  Diffusion_state .
## 
## Total effect(c) of  Altruism_avg  on  HelpBehave  =  0.16   S.E. =  0.04  t  =  3.96  df=  219   with p =  1e-04
## Direct effect (c') of  Altruism_avg  on  HelpBehave  removing  Diffusion_state  =  0.02   S.E. =  0.05  t  =  0.33  df=  218   with p =  0.74
## Indirect effect (ab) of  Altruism_avg  on  HelpBehave  through  Diffusion_state   =  0.14 
## Mean bootstrapped indirect effect =  0.14  with standard error =  0.03  Lower CI =  0.08    Upper CI =  0.2
## R = 0.4 R2 = 0.16   F = 21.04 on 2 and 218 DF   p-value:  5.19e-12 
## 
##  To see the longer output, specify short = FALSE in the print statement or ask for the summary
summary(mediate(HelpBehave ~ Altruism_avg + (Diffusion_state), data = listwise.PS3.Q2, n.iter = 5000))

## Call: mediate(y = HelpBehave ~ Altruism_avg + (Diffusion_state), data = listwise.PS3.Q2, 
##     n.iter = 5000)
## 
## Direct effect estimates (traditional regression)    (c') X + M on Y 
##                 HelpBehave   se     t  df     Prob
## Intercept             2.77 0.23 12.19 218 2.02e-26
## Altruism_avg          0.02 0.05  0.33 218 7.44e-01
## Diffusion_state       0.18 0.04  4.97 218 1.33e-06
## 
## R = 0.4 R2 = 0.16   F = 21.04 on 2 and 218 DF   p-value:  4.4e-09 
## 
##  Total effect estimates (c) (X on Y) 
##              HelpBehave   se     t  df     Prob
## Intercept          2.32 0.22 10.58 219 2.17e-21
## Altruism_avg       0.16 0.04  3.96 219 1.03e-04
## 
##  'a'  effect estimates (X on M) 
##              Diffusion_state   se     t  df     Prob
## Intercept              -2.52 0.40 -6.34 219 1.30e-09
## Altruism_avg            0.80 0.07 11.17 219 3.11e-23
## 
##  'b'  effect estimates (M on Y controlling for X) 
##                 HelpBehave   se    t  df     Prob
## Diffusion_state       0.18 0.04 4.97 218 1.33e-06
## 
##  'ab'  effect estimates (through all  mediators)
##              HelpBehave boot   sd lower upper
## Altruism_avg       0.14 0.14 0.03  0.08   0.2

Reporting the a-path, b-path, and c’ (c prime) path coefficient, and reporting the c-path as a reference is the tradition.

2j) The size of the ab-path is .14. The size of the c’ is .02. We need these two values to calculate P\(_{M}\) (“proportion” mediated).

calculating the Effect Size for Mediation ab/(ab+c’)

Proportion.Mediated = .14/(.14 + .02)
Proportion.Mediated
## [1] 0.875

The effect size is large, P\(_{M}\) = .875.

APA Style Conclusion

A mediation analysis tested the hypothesis that state of diffusion responsibility mediates the relationship between trait altruism and helping behavior (n = 221). The mediation analysis was conducted using the bootstrap method (version 1.8.4; Ravelle, 2018) with 5,000 resamples using the psych package in R (R core team, 2018). The initial path showed that trait altruism positively predicted helping behavior b = 0.16, p < .001. Trait altruism also positively predicted state of diffusion responsibility scores b=0.8, p<.001. state of diffusion responsibility scores positively predicted helping behavior scores, when controlling for trait altruism, b= 0.18, p< .001. Controlling for diffusion state scores the direct effect of trait altruism was attenuated and no longer statistically significant b= .02, p= .70. The 95% confidence interval (bias corrected and accelerated) for the indirect effect ( b = .14) did not include zero [.08, .20], indicating that meditation likely occurred, P\(_{M}\) = .875.