The following are my Honors Thesis mediation analyses using a composite score for maternal sensitivity.
## Load dataset
library(haven)
baby2.0comp <- read_sav("TheaWulff_DatasetSensComp.sav")
## Rename columns for readability using dplyr
library(dplyr)
##
## Attaching package: 'dplyr'
## The following objects are masked from 'package:stats':
##
## filter, lag
## The following objects are masked from 'package:base':
##
## intersect, setdiff, setequal, union
baby2.0comp <- baby2.0comp %>%
rename(DERS = DERStotmA,
SensitivityComposite = OverallMaternalSensitivity,
ITSEA_dysreg = ITSEAdysTmD1,
ITSEA_exter = ITSEAextTmD1,
ITSEA_inter = ITSEAintTmD1,
ITSEA_comp = ITSEAcompTmD1)
The goal is to run a mediation analysis with the following variables.
Independent variable: DERS
Mediating variable: SensitivityComposite
Dependent variable(s): ITSEA_dysreg, ITSEA_exter, ITSEA_inter, ITSEA_comp
I will also use full information maximum likelihood to account for missing data.
Let’s load the packages we need to achieve this goal.
library(mediation)
## Loading required package: MASS
##
## Attaching package: 'MASS'
## The following object is masked from 'package:dplyr':
##
## select
## Loading required package: Matrix
## Loading required package: mvtnorm
## Loading required package: sandwich
## mediation: Causal Mediation Analysis
## Version: 4.5.0
library(lavaan)
## This is lavaan 0.6-18
## lavaan is FREE software! Please report any bugs.
ITSEA Dysregulation
Let’s specify the mediation module for the first of four analyses: ITSEA_dysreg
mediation_model <- '
# Mediator model
SensitivityComposite ~ a * DERS
# Outcome model
ITSEA_dysreg ~ b * SensitivityComposite + c * DERS
# Indirect effect (mediation effect)
indirect_effect := a * b
# Direct effect
direct_effect := c
# Total effect
total_effect := indirect_effect + direct_effect
'
## Account for missing data using Full Information Maximum Likelihood (FIML).
## Possible through the Lavaan package
fit <- sem(mediation_model, data = baby2.0comp, missing = "fiml")
## Warning: lavaan->lav_data_full():
## 2 cases were deleted due to missing values in exogenous variable(s), while
## fixed.x = TRUE.
summary(fit, standardized = TRUE, fit.measures = TRUE)
## lavaan 0.6-18 ended normally after 21 iterations
##
## Estimator ML
## Optimization method NLMINB
## Number of model parameters 7
##
## Used Total
## Number of observations 383 385
## Number of missing patterns 4
##
## Model Test User Model:
##
## Test statistic 0.000
## Degrees of freedom 0
##
## Model Test Baseline Model:
##
## Test statistic 11.467
## Degrees of freedom 3
## P-value 0.009
##
## User Model versus Baseline Model:
##
## Comparative Fit Index (CFI) 1.000
## Tucker-Lewis Index (TLI) 1.000
##
## Robust Comparative Fit Index (CFI) 1.000
## Robust Tucker-Lewis Index (TLI) 1.000
##
## Loglikelihood and Information Criteria:
##
## Loglikelihood user model (H0) -1403.331
## Loglikelihood unrestricted model (H1) -1403.331
##
## Akaike (AIC) 2820.661
## Bayesian (BIC) 2848.298
## Sample-size adjusted Bayesian (SABIC) 2826.088
##
## Root Mean Square Error of Approximation:
##
## RMSEA 0.000
## 90 Percent confidence interval - lower 0.000
## 90 Percent confidence interval - upper 0.000
## P-value H_0: RMSEA <= 0.050 NA
## P-value H_0: RMSEA >= 0.080 NA
##
## Robust RMSEA 0.000
## 90 Percent confidence interval - lower 0.000
## 90 Percent confidence interval - upper 0.000
## P-value H_0: Robust RMSEA <= 0.050 NA
## P-value H_0: Robust RMSEA >= 0.080 NA
##
## Standardized Root Mean Square Residual:
##
## SRMR 0.000
##
## Parameter Estimates:
##
## Standard errors Standard
## Information Observed
## Observed information based on Hessian
##
## Regressions:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## SensitivityComposite ~
## DERS (a) -0.003 0.002 -1.458 0.145 -0.003 -0.093
## ITSEA_dysreg ~
## SnstvtyCmp (b) -0.512 1.149 -0.446 0.656 -0.512 -0.030
## DERS (c) 0.085 0.028 3.000 0.003 0.085 0.177
##
## Intercepts:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## .SensitvtyCmpst 3.787 0.150 25.275 0.000 3.787 5.323
## .ITSEA_dysreg 38.560 4.939 7.807 0.000 38.560 3.187
##
## Variances:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## .SensitvtyCmpst 0.502 0.044 11.446 0.000 0.502 0.991
## .ITSEA_dysreg 141.561 11.800 11.997 0.000 141.561 0.967
##
## Defined Parameters:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## indirect_effct 0.001 0.003 0.425 0.671 0.001 0.003
## direct_effect 0.085 0.028 3.000 0.003 0.085 0.177
## total_effect 0.086 0.028 3.059 0.002 0.086 0.180
The indirect effect is not significant (p=0.671), meaning that mediation (indirect effect) between the DERS and ITSEA_dysreg via the mediator (SensitivityComposite) is not significant.
The direct effect is significant (p=0.003). DERS has a significant direct impact on ITSEA_dysreg.
ITSEA Externalizing
Let’s specify the mediation module for the second of four analyses: ITSEA_exter
mediation_model <- '
# Mediator model
SensitivityComposite ~ a * DERS
# Outcome model
ITSEA_exter ~ b * SensitivityComposite + c * DERS
# Indirect effect (mediation effect)
indirect_effect := a * b
# Direct effect
direct_effect := c
# Total effect
total_effect := indirect_effect + direct_effect
'
fit <- sem(mediation_model, data = baby2.0comp, missing = "fiml")
## Warning: lavaan->lav_data_full():
## 2 cases were deleted due to missing values in exogenous variable(s), while
## fixed.x = TRUE.
summary(fit, standardized = TRUE, fit.measures = TRUE)
## lavaan 0.6-18 ended normally after 22 iterations
##
## Estimator ML
## Optimization method NLMINB
## Number of model parameters 7
##
## Used Total
## Number of observations 383 385
## Number of missing patterns 4
##
## Model Test User Model:
##
## Test statistic 0.000
## Degrees of freedom 0
##
## Model Test Baseline Model:
##
## Test statistic 13.012
## Degrees of freedom 3
## P-value 0.005
##
## User Model versus Baseline Model:
##
## Comparative Fit Index (CFI) 1.000
## Tucker-Lewis Index (TLI) 1.000
##
## Robust Comparative Fit Index (CFI) 1.000
## Robust Tucker-Lewis Index (TLI) 1.000
##
## Loglikelihood and Information Criteria:
##
## Loglikelihood user model (H0) -1073.641
## Loglikelihood unrestricted model (H1) -1073.641
##
## Akaike (AIC) 2161.283
## Bayesian (BIC) 2188.919
## Sample-size adjusted Bayesian (SABIC) 2166.709
##
## Root Mean Square Error of Approximation:
##
## RMSEA 0.000
## 90 Percent confidence interval - lower 0.000
## 90 Percent confidence interval - upper 0.000
## P-value H_0: RMSEA <= 0.050 NA
## P-value H_0: RMSEA >= 0.080 NA
##
## Robust RMSEA 0.000
## 90 Percent confidence interval - lower 0.000
## 90 Percent confidence interval - upper 0.000
## P-value H_0: Robust RMSEA <= 0.050 NA
## P-value H_0: Robust RMSEA >= 0.080 NA
##
## Standardized Root Mean Square Residual:
##
## SRMR 0.000
##
## Parameter Estimates:
##
## Standard errors Standard
## Information Observed
## Observed information based on Hessian
##
## Regressions:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## SensitivityComposite ~
## DERS (a) -0.003 0.002 -1.429 0.153 -0.003 -0.091
## ITSEA_exter ~
## SnstvtyCmp (b) -1.489 0.921 -1.617 0.106 -1.489 -0.132
## DERS (c) 0.064 0.022 2.902 0.004 0.064 0.201
##
## Intercepts:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## .SensitvtyCmpst 3.784 0.150 25.259 0.000 3.784 5.316
## .ITSEA_exter 48.642 3.821 12.730 0.000 48.642 6.044
##
## Variances:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## .SensitvtyCmpst 0.502 0.044 11.432 0.000 0.502 0.992
## .ITSEA_exter 60.716 5.726 10.604 0.000 60.716 0.937
##
## Defined Parameters:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## indirect_effct 0.004 0.004 1.080 0.280 0.004 0.012
## direct_effect 0.064 0.022 2.902 0.004 0.064 0.201
## total_effect 0.068 0.022 3.050 0.002 0.068 0.213
The indirect effect is not significant (p=0.280), meaning that mediation (indirect effect) between the DERS and ITSEA_exter via the mediator (SensitivityComposite) is not significant.
The direct effect is significant (p=0.004). DERS has a significant direct impact on ITSEA_exter.
ITSEA Internalizing
Let’s specify the mediation module for the third of four analyses: ITSEA_inter
mediation_model <- '
# Mediator model
SensitivityComposite ~ a * DERS
# Outcome model
ITSEA_inter ~ b * SensitivityComposite + c * DERS
# Indirect effect (mediation effect)
indirect_effect := a * b
# Direct effect
direct_effect := c
# Total effect
total_effect := indirect_effect + direct_effect
'
fit <- sem(mediation_model, data = baby2.0comp, missing = "fiml")
## Warning: lavaan->lav_data_full():
## 2 cases were deleted due to missing values in exogenous variable(s), while
## fixed.x = TRUE.
summary(fit, standardized = TRUE, fit.measures = TRUE)
## lavaan 0.6-18 ended normally after 20 iterations
##
## Estimator ML
## Optimization method NLMINB
## Number of model parameters 7
##
## Used Total
## Number of observations 383 385
## Number of missing patterns 4
##
## Model Test User Model:
##
## Test statistic 0.000
## Degrees of freedom 0
##
## Model Test Baseline Model:
##
## Test statistic 10.856
## Degrees of freedom 3
## P-value 0.013
##
## User Model versus Baseline Model:
##
## Comparative Fit Index (CFI) 1.000
## Tucker-Lewis Index (TLI) 1.000
##
## Robust Comparative Fit Index (CFI) 1.000
## Robust Tucker-Lewis Index (TLI) 1.000
##
## Loglikelihood and Information Criteria:
##
## Loglikelihood user model (H0) -1361.168
## Loglikelihood unrestricted model (H1) -1361.168
##
## Akaike (AIC) 2736.337
## Bayesian (BIC) 2763.973
## Sample-size adjusted Bayesian (SABIC) 2741.763
##
## Root Mean Square Error of Approximation:
##
## RMSEA 0.000
## 90 Percent confidence interval - lower 0.000
## 90 Percent confidence interval - upper 0.000
## P-value H_0: RMSEA <= 0.050 NA
## P-value H_0: RMSEA >= 0.080 NA
##
## Robust RMSEA 0.000
## 90 Percent confidence interval - lower 0.000
## 90 Percent confidence interval - upper 0.000
## P-value H_0: Robust RMSEA <= 0.050 NA
## P-value H_0: Robust RMSEA >= 0.080 NA
##
## Standardized Root Mean Square Residual:
##
## SRMR 0.000
##
## Parameter Estimates:
##
## Standard errors Standard
## Information Observed
## Observed information based on Hessian
##
## Regressions:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## SensitivityComposite ~
## DERS (a) -0.003 0.002 -1.470 0.142 -0.003 -0.093
## ITSEA_inter ~
## SnstvtyCmp (b) 1.576 1.025 1.537 0.124 1.576 0.103
## DERS (c) 0.069 0.025 2.703 0.007 0.069 0.160
##
## Intercepts:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## .SensitvtyCmpst 3.790 0.150 25.315 0.000 3.790 5.327
## .ITSEA_inter 38.494 4.438 8.674 0.000 38.494 3.544
##
## Variances:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## .SensitvtyCmpst 0.502 0.044 11.446 0.000 0.502 0.991
## .ITSEA_inter 114.071 9.583 11.904 0.000 114.071 0.967
##
## Defined Parameters:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## indirect_effct -0.004 0.004 -1.057 0.291 -0.004 -0.010
## direct_effect 0.069 0.025 2.703 0.007 0.069 0.160
## total_effect 0.065 0.025 2.545 0.011 0.065 0.150
The indirect effect is not significant (p=0.291), meaning that mediation (indirect effect) between the DERS and ITSEA_inter via the mediator (SensitivityComposite) is not significant.
The direct effect is significant (p=0.007). DERS has a significant direct impact on ITSEA_inter.
ITSEA Competence
Let’s specify the mediation module for the fourth of four analyses: ITSEA_comp
mediation_model <- '
# Mediator model
SensitivityComposite ~ a * DERS
# Outcome model
ITSEA_comp ~ b * SensitivityComposite + c * DERS
# Indirect effect (mediation effect)
indirect_effect := a * b
# Direct effect
direct_effect := c
# Total effect
total_effect := indirect_effect + direct_effect
'
fit <- sem(mediation_model, data = baby2.0comp, missing = "fiml")
## Warning: lavaan->lav_data_full():
## 2 cases were deleted due to missing values in exogenous variable(s), while
## fixed.x = TRUE.
summary(fit, standardized = TRUE, fit.measures = TRUE)
## lavaan 0.6-18 ended normally after 22 iterations
##
## Estimator ML
## Optimization method NLMINB
## Number of model parameters 7
##
## Used Total
## Number of observations 383 385
## Number of missing patterns 4
##
## Model Test User Model:
##
## Test statistic 0.000
## Degrees of freedom 0
##
## Model Test Baseline Model:
##
## Test statistic 2.269
## Degrees of freedom 3
## P-value 0.519
##
## User Model versus Baseline Model:
##
## Comparative Fit Index (CFI) 1.000
## Tucker-Lewis Index (TLI) 1.000
##
## Robust Comparative Fit Index (CFI) 1.000
## Robust Tucker-Lewis Index (TLI) 1.000
##
## Loglikelihood and Information Criteria:
##
## Loglikelihood user model (H0) -1085.990
## Loglikelihood unrestricted model (H1) -1085.990
##
## Akaike (AIC) 2185.979
## Bayesian (BIC) 2213.616
## Sample-size adjusted Bayesian (SABIC) 2191.406
##
## Root Mean Square Error of Approximation:
##
## RMSEA 0.000
## 90 Percent confidence interval - lower 0.000
## 90 Percent confidence interval - upper 0.000
## P-value H_0: RMSEA <= 0.050 NA
## P-value H_0: RMSEA >= 0.080 NA
##
## Robust RMSEA 0.000
## 90 Percent confidence interval - lower 0.000
## 90 Percent confidence interval - upper 0.000
## P-value H_0: Robust RMSEA <= 0.050 NA
## P-value H_0: Robust RMSEA >= 0.080 NA
##
## Standardized Root Mean Square Residual:
##
## SRMR 0.000
##
## Parameter Estimates:
##
## Standard errors Standard
## Information Observed
## Observed information based on Hessian
##
## Regressions:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## SensitivityComposite ~
## DERS (a) -0.003 0.002 -1.447 0.148 -0.003 -0.092
## ITSEA_comp ~
## SnstvtyCmp (b) 0.261 1.061 0.246 0.805 0.261 0.020
## DERS (c) -0.009 0.027 -0.324 0.746 -0.009 -0.023
##
## Intercepts:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## .SensitvtyCmpst 3.787 0.150 25.266 0.000 3.787 5.322
## .ITSEA_comp 46.536 4.477 10.394 0.000 46.536 4.879
##
## Variances:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## .SensitvtyCmpst 0.502 0.044 11.446 0.000 0.502 0.992
## .ITSEA_comp 90.867 8.684 10.464 0.000 90.867 0.999
##
## Defined Parameters:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## indirect_effct -0.001 0.003 -0.244 0.807 -0.001 -0.002
## direct_effect -0.009 0.027 -0.324 0.746 -0.009 -0.023
## total_effect -0.010 0.027 -0.347 0.728 -0.010 -0.025
The indirect effect is not significant (p=0.807), meaning that mediation (indirect effect) between the DERS and ITSEA_comp via the mediator (SensitivityComposite) is not significant.
The direct effect is also note significant (p=0.746). DERS does not have a significant direct impact on ITSEA_comp.
Conclusion: The mediation (indirect effect) between the DERS and all four of the ITSEA outcomes via the mediator (SensitivityComposite) is not significant.