The data used in these analyses comes from the Early Experiences Lab BABY Affect and Behavior (BABY 1.0) study at the University of Utah, overseen by Dr. Lee Raby.
These analyses are likely to be used in my Honors thesis, which will be completed in spring of 2025. My complete Honors thesis proposal is linked here.
Let’s load the dataset.
library(haven)
baby <- read_sav("theadata_baby1.0.sav")
The column names are a bit messy, so let’s rename them 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
baby <- baby %>%
rename(DERS = DERStotmA,
Sensitivity_to_ND = FreePlay_Toy_OverallParentingQuality,
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: Sensitivity_to_ND - Dependent variable: ITSEA_exter
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.
Now we need to specify the mediation model.
mediation_model <- '
# Mediator model
Sensitivity_to_ND ~ a * DERS
# Outcome model
ITSEA_exter ~ b * Sensitivity_to_ND + c * DERS
# Indirect effect (mediation effect)
indirect_effect := a * b
# Direct effect
direct_effect := c
# Total effect
total_effect := indirect_effect + direct_effect
'
And then we can run the analysis. The lavaan package accounts for missing data using Full Information Maximum Likelihood (FIML).
fit <- sem(mediation_model, data = baby, 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 160 162
## Number of missing patterns 4
##
## Model Test User Model:
##
## Test statistic 0.000
## Degrees of freedom 0
##
## Model Test Baseline Model:
##
## Test statistic 17.163
## Degrees of freedom 3
## P-value 0.001
##
## 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) -507.153
## Loglikelihood unrestricted model (H1) -507.153
##
## Akaike (AIC) 1028.306
## Bayesian (BIC) 1049.832
## Sample-size adjusted Bayesian (SABIC) 1027.673
##
## 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
## Sensitivity_to_ND ~
## DERS (a) -0.006 0.003 -1.951 0.051 -0.006 -0.199
## ITSEA_exter ~
## Snstvt__ND (b) -2.019 1.432 -1.410 0.159 -2.019 -0.164
## DERS (c) 0.091 0.031 2.922 0.003 0.091 0.264
##
## Intercepts:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## .Sensitvty_t_ND 3.755 0.237 15.830 0.000 3.755 5.055
## .ITSEA_exter 49.940 6.077 8.218 0.000 49.940 5.453
##
## Variances:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## .Sensitvty_t_ND 0.530 0.075 7.045 0.000 0.530 0.961
## .ITSEA_exter 74.349 10.120 7.346 0.000 74.349 0.886
##
## Defined Parameters:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## indirect_effct 0.011 0.010 1.174 0.241 0.011 0.033
## direct_effect 0.091 0.031 2.922 0.003 0.091 0.264
## total_effect 0.102 0.030 3.387 0.001 0.102 0.296
The indirect effect (mediation) is not significant, suggesting that the mediator (Sensitivity_to_ND) does not significantly mediate the relationship between DERS and ITSEA_exter.