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)
summary(fit, standardized = TRUE, fit.measures = TRUE)
## lavaan 0.6-18 ended normally after 1 iteration
## 
##   Estimator                                         ML
##   Optimization method                           NLMINB
##   Number of model parameters                         5
## 
##                                                   Used       Total
##   Number of observations                            86         162
## 
## Model Test User Model:
##                                                       
##   Test statistic                                 0.000
##   Degrees of freedom                                 0
## 
## Model Test Baseline Model:
## 
##   Test statistic                                19.555
##   Degrees of freedom                                 3
##   P-value                                        0.000
## 
## User Model versus Baseline Model:
## 
##   Comparative Fit Index (CFI)                    1.000
##   Tucker-Lewis Index (TLI)                       1.000
## 
## Loglikelihood and Information Criteria:
## 
##   Loglikelihood user model (H0)               -391.220
##   Loglikelihood unrestricted model (H1)       -391.220
##                                                       
##   Akaike (AIC)                                 792.439
##   Bayesian (BIC)                               804.711
##   Sample-size adjusted Bayesian (SABIC)        788.936
## 
## 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
## 
## Standardized Root Mean Square Residual:
## 
##   SRMR                                           0.000
## 
## Parameter Estimates:
## 
##   Standard errors                             Standard
##   Information                                 Expected
##   Information saturated (h1) model          Structured
## 
## Regressions:
##                       Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
##   Sensitivity_to_ND ~                                                      
##     DERS       (a)      -0.007    0.003   -2.332    0.020   -0.007   -0.244
##   ITSEA_exter ~                                                            
##     Snstvt__ND (b)      -1.625    1.252   -1.297    0.195   -1.625   -0.133
##     DERS       (c)       0.110    0.034    3.294    0.001    0.110    0.337
## 
## Variances:
##                    Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
##    .Sensitvty_t_ND    0.477    0.073    6.557    0.000    0.477    0.941
##    .ITSEA_exter      64.295    9.805    6.557    0.000   64.295    0.847
## 
## Defined Parameters:
##                    Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
##     indirect_effct    0.011    0.009    1.134    0.257    0.011    0.032
##     direct_effect     0.110    0.034    3.294    0.001    0.110    0.337
##     total_effect      0.121    0.033    3.686    0.000    0.121    0.369

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.