setwd("C:/Users/bear2/Desktop/lab meeting/study")
study2<-read.csv(file="Data_study2.csv",header=TRUE)
View(study2)

Mediation1: Social skill-Decentering-GERT negreg score (group1)

study2_1<-split(study2,study2$RECGROUP)

fit1_1<-lm(Decentering~SS,data=study2_1$"1")
fit1_2<-lm(negregscore~SS+Decentering,data=study2_1$"1")
fit1<-mediate(fit1_1,fit1_2,treat="SS",mediator="Decentering")
summary(fit1)
## 
## Causal Mediation Analysis 
## 
## Quasi-Bayesian Confidence Intervals
## 
##                Estimate 95% CI Lower 95% CI Upper p-value  
## ACME             -0.333       -0.775        -0.01   0.044 *
## ADE              -0.282       -1.044         0.46   0.442  
## Total Effect     -0.615       -1.300         0.08   0.094 .
## Prop. Mediated    0.504       -3.760         4.21   0.138  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Sample Size Used: 59 
## 
## 
## Simulations: 1000
plot(fit1)

Mediation2: Decentering-GERT negreg score-Social skill (group1)

fit2_1<-lm(negregscore~Decentering,data=study2_1$"1")
fit2_2<-lm(SS~Decentering+negregscore,data=study2_1$"1")
fit2<-mediate(fit2_1,fit2_2,treat="Decentering",mediator="negregscore")
summary(fit2)
## 
## Causal Mediation Analysis 
## 
## Quasi-Bayesian Confidence Intervals
## 
##                Estimate 95% CI Lower 95% CI Upper p-value   
## ACME             0.0236      -0.0348         0.10   0.474   
## ADE              0.3051       0.1099         0.50   0.002 **
## Total Effect     0.3287       0.1460         0.51   0.002 **
## Prop. Mediated   0.0632      -0.1189         0.35   0.476   
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Sample Size Used: 59 
## 
## 
## Simulations: 1000
plot(fit2)

Mediation3: GERT negreg score-Social skill-Decentering (group1)

fit3_1<-lm(SS~negregscore,data=study2_1$"1")
fit3_2<-lm(Decentering~negregscore+SS,data=study2_1$"1")
fit3<-mediate(fit3_1,fit3_2,treat="negregscore",mediator="SS")
summary(fit3)
## 
## Causal Mediation Analysis 
## 
## Quasi-Bayesian Confidence Intervals
## 
##                Estimate 95% CI Lower 95% CI Upper p-value  
## ACME            -0.0469      -0.1161         0.00   0.066 .
## ADE             -0.1250      -0.2459         0.00   0.046 *
## Total Effect    -0.1719      -0.3055        -0.04   0.016 *
## Prop. Mediated   0.2610      -0.0597         0.86   0.078 .
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Sample Size Used: 59 
## 
## 
## Simulations: 1000
plot(fit3)

Mediation4: Social skill-GERT negreg score-Decentering (group1)

fit4_1<-lm(negregscore~SS,data=study2_1$"1")
fit4_2<-lm(Decentering~SS+negregscore,data=study2_1$"1")
fit4<-mediate(fit4_1,fit4_2,treat="SS",mediator="negregscore")
summary(fit4)
## 
## Causal Mediation Analysis 
## 
## Quasi-Bayesian Confidence Intervals
## 
##                Estimate 95% CI Lower 95% CI Upper p-value    
## ACME             0.0781      -0.0105         0.22    0.11    
## ADE              0.5337       0.2247         0.85  <2e-16 ***
## Total Effect     0.6118       0.2896         0.92  <2e-16 ***
## Prop. Mediated   0.1153      -0.0212         0.40    0.11    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Sample Size Used: 59 
## 
## 
## Simulations: 1000
plot(fit4)

Mediation5: GERT negreg score-Decentering-Social skill (group1)

fit5_1<-lm(Decentering~negregscore,data=study2_1$"1")
fit5_2<-lm(SS~Decentering+negregscore,data=study2_1$"1")
fit5<-mediate(fit5_1,fit5_2,treat="negregscore",mediator="Decentering")
summary(fit5)
## 
## Causal Mediation Analysis 
## 
## Quasi-Bayesian Confidence Intervals
## 
##                Estimate 95% CI Lower 95% CI Upper p-value   
## ACME            -0.0511      -0.1078        -0.01   0.004 **
## ADE             -0.0365      -0.1320         0.06   0.428   
## Total Effect    -0.0876      -0.1857         0.01   0.092 . 
## Prop. Mediated   0.5336      -1.2558         2.66   0.096 . 
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Sample Size Used: 59 
## 
## 
## Simulations: 1000
plot(fit5)

Mediation6: Decentering-Social skill-GERT negreg score (group1)

fit6_1<-lm(SS~Decentering,data=study2_1$"1")
fit6_2<-lm(negregscore~Decentering+SS,data=study2_1$"1")
fit6<-mediate(fit6_1,fit6_2,treat="Decentering",mediator="SS")
summary(fit6)
## 
## Causal Mediation Analysis 
## 
## Quasi-Bayesian Confidence Intervals
## 
##                Estimate 95% CI Lower 95% CI Upper p-value  
## ACME            -0.0976      -0.3865         0.14   0.410  
## ADE             -0.5317      -1.0332         0.00   0.056 .
## Total Effect    -0.6293      -1.0921        -0.14   0.020 *
## Prop. Mediated   0.1447      -0.3414         0.91   0.418  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Sample Size Used: 59 
## 
## 
## Simulations: 1000
plot(fit6)

Mediation7: Social skill-Decentering-GERT negright score (group1)

fit7_1<-lm(Decentering~SS,data=study2_1$"1")
fit7_2<-lm(negright~SS+Decentering,data=study2_1$"1")
fit7<-mediate(fit7_1,fit7_2,treat="SS",mediator="Decentering")
summary(fit7)
## 
## Causal Mediation Analysis 
## 
## Quasi-Bayesian Confidence Intervals
## 
##                Estimate 95% CI Lower 95% CI Upper p-value
## ACME             -0.322       -1.033         0.25    0.28
## ADE              -0.546       -1.782         0.82    0.42
## Total Effect     -0.869       -2.019         0.32    0.16
## Prop. Mediated    0.268       -2.757         4.30    0.40
## 
## Sample Size Used: 59 
## 
## 
## Simulations: 1000
plot(fit7)

Mediation8: Decentering-GERT negright score-Social skill (group1)

fit8_1<-lm(negright~Decentering,data=study2_1$"1")
fit8_2<-lm(SS~Decentering+negright,data=study2_1$"1")
fit8<-mediate(fit8_1,fit8_2,treat="Decentering",mediator="negright")
summary(fit8)
## 
## Causal Mediation Analysis 
## 
## Quasi-Bayesian Confidence Intervals
## 
##                Estimate 95% CI Lower 95% CI Upper p-value    
## ACME             0.0171      -0.0257         0.08    0.44    
## ADE              0.3079       0.1433         0.50  <2e-16 ***
## Total Effect     0.3250       0.1563         0.51  <2e-16 ***
## Prop. Mediated   0.0415      -0.0863         0.26    0.44    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Sample Size Used: 59 
## 
## 
## Simulations: 1000
plot(fit8)

Mediation9: GERT negright-Social skill-Decentering (group1)

fit9_1<-lm(SS~negright,data=study2_1$"1")
fit9_2<-lm(Decentering~negright+SS,data=study2_1$"1")
fit9<-mediate(fit9_1,fit9_2,treat="negright",mediator="SS")
summary(fit9)
## 
## Causal Mediation Analysis 
## 
## Quasi-Bayesian Confidence Intervals
## 
##                Estimate 95% CI Lower 95% CI Upper p-value
## ACME            -0.0257      -0.0644         0.00    0.12
## ADE             -0.0396      -0.1105         0.03    0.25
## Total Effect    -0.0652      -0.1440         0.01    0.10
## Prop. Mediated   0.3655      -1.1190         1.90    0.17
## 
## Sample Size Used: 59 
## 
## 
## Simulations: 1000
plot(fit9)

Mediation10: Social skill-GERT negright score-Decentering (group1)

fit10_1<-lm(negright~SS,data=study2_1$"1")
fit10_2<-lm(Decentering~SS+negright,data=study2_1$"1")
fit10<-mediate(fit10_1,fit10_2,treat="SS",mediator="negright")
summary(fit10)
## 
## Causal Mediation Analysis 
## 
## Quasi-Bayesian Confidence Intervals
## 
##                Estimate 95% CI Lower 95% CI Upper p-value    
## ACME             0.0345      -0.0406         0.16    0.43    
## ADE              0.5789       0.2556         0.90  <2e-16 ***
## Total Effect     0.6134       0.2957         0.93  <2e-16 ***
## Prop. Mediated   0.0412      -0.0818         0.28    0.43    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Sample Size Used: 59 
## 
## 
## Simulations: 1000
plot(fit10)

Mediation11: GERT negright score-Decentering-Social skill (group1)

fit11_1<-lm(Decentering~negright,data=study2_1$"1")
fit11_2<-lm(SS~Decentering+negright,data=study2_1$"1")
fit11<-mediate(fit11_1,fit11_2,treat="negright",mediator="Decentering")
summary(fit11)
## 
## Causal Mediation Analysis 
## 
## Quasi-Bayesian Confidence Intervals
## 
##                Estimate 95% CI Lower 95% CI Upper p-value  
## ACME            -0.0206      -0.0516         0.00    0.09 .
## ADE             -0.0247      -0.0750         0.03    0.33  
## Total Effect    -0.0453      -0.1018         0.01    0.11  
## Prop. Mediated   0.4077      -0.7899         2.83    0.15  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Sample Size Used: 59 
## 
## 
## Simulations: 1000
plot(fit11)

Mediation12: Decentering-Social skill-GERT negright score (group1)

fit12_1<-lm(SS~Decentering,data=study2_1$"1")
fit12_2<-lm(negright~Decentering+SS,data=study2_1$"1")
fit12<-mediate(fit12_1,fit12_2,treat="Decentering",mediator="SS")
summary(fit12)
## 
## Causal Mediation Analysis 
## 
## Quasi-Bayesian Confidence Intervals
## 
##                Estimate 95% CI Lower 95% CI Upper p-value
## ACME             -0.194       -0.647         0.22    0.36
## ADE              -0.523       -1.424         0.42    0.29
## Total Effect     -0.717       -1.568         0.20    0.10
## Prop. Mediated    0.224       -0.977         2.68    0.43
## 
## Sample Size Used: 59 
## 
## 
## Simulations: 1000
plot(fit12)