R: MICE. How to obtain standardized coefficients of a mediation analysis after multiple imputation

Hi,
I would like to conduct a mediation analysis with standardized coefficients.
Since my data set contains missing data, I impute them with MICE multiple imputation. For me, it makes sense to standardize my variables after imputation.
This is the code I used for z-standardisation:

#--- impute data df
imp <- mice(df, m=5, seed = 1234)
complete(imp)
#--- convert into datlist
datlist <- miceadds::mids2datlist(imp)
#--- scale datlist (only numeric variables: 1-7)
vars <- colnames(df[,1:7] )
sdatlist <- miceadds::scale_datlist(datlist, orig_var=vars, trafo_var=paste0("z",vars))
#--- reconvert to mids object
imp2 <- miceadds::datlist2mids(sdatlist)
imp2
complete(imp2)

Now I would like to use the imputed datasets with the standardized variable for my mediation.
This is the code I intend to use for the mediation:

mediation <-'
scaleQIDS_t1 ~ direfModuleEr + bWAI_P + QIDS_t0 + eCoach.d2 + eCoach.d3 + eCoach.d4 +
eCoach.d5 + eCoach.d6 + eCoach.d7 + eCoach.d8 + eCoach.d9 + eCoach.d10

WAI_P ~ aModuleEr + QIDS_t0 + eCoach.d2 + eCoach.d3 + eCoach.d4 +
eCoach.d5 + eCoach.d6 + eCoach.d7 + eCoach.d8 + eCoach.d9 + eCoach.d10
indef := a
b

total := indef + diref
'

analysis based on all imputed datasets

mod6b <- lapply( imp3 , FUN = function(data){
res <- lavaan::sem(mediation , data = df )
return(res)
} )

extract all parameters

qhat <- lapply( mod6b , FUN = function(ll){
h1 <- lavaan::parameterEstimates(ll)
parnames <- paste0( h1$lhs , h1$op , h1$rhs )
v1 <- h1$est
names(v1) <- parnames
return(v1)
} )
se <- lapply( mod6b , FUN = function(ll){
h1 <- lavaan::parameterEstimates(ll)
parnames <- paste0( h1$lhs , h1$op , h1$rhs )
v1 <- h1$se
names(v1) <- parnames
return(v1)
} )

Unfortunately, the code refers to the original data df with missing data. df does not yet contain any standardizes zVariables. so if I would write zQIDS_t1 in my mediation model, it wouldn't work..
so here is my question:
How can I obtain standardized coefficients of my mediation model after multiple imputation.
Thanks a lot!

Your code is not easily readable. Please copy it from your R session and enclose it with 3 backticks before and after in your posting to make it better readable.

I am not an expert on mediation analysis and imputation so I probably can't help you.
However I would expect that this code would not run because the imp3 variable is nowhere defined in your code. Also I don't see which packages you are using. So you probably did not insert all code.

The best way to avoid these issues is to present a reprex. This will at the same time resolve the formatting issue.

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.