harrelfe / rms

Regression Modeling Strategies
https://hbiostat.org/R/rms
Other
172 stars 48 forks source link

Estimating contrasts and marginal effects from aregImpute multiply imputed data #141

Open martinspn opened 6 months ago

martinspn commented 6 months ago

Hi. I am looking for a way to perform multiple imputation using nonlinear predictors and then analyze data considering these predictors as nonlinear terms. I came across aregImpute after some research and it's been very handy so thanks a lot for it.

Besides evaluating nonlinear effects, I want to assess the marginal effects of a continuous variable on the probability of a dichotomous outcome. While it's quite straightforward to obtain the model predictions using fit.mult.impute with fitter = lrm or fitter = glm, I am having a hard time estimating the slopes and contrasts. I had done it previously with the complete-case analysis through applying marginaleffects's functions to a mgcv::gam() model with a binomial link. Now I am trying to re-do it with multiply imputed data since we have ~20% missing outcome values and a few missing covariates too.

When I call class(model) using the fit.mult.impute object, I get

> class(model_fitmultimpute)
[1] "fit.mult.impute" "lrm"             "rms"             "glm" 

Is it possible to extract the glm/lrm part of the object with a view to making it compatible with marginaleffects? Or would you recommend any other way for estimating such contrasts?

Thanks in advance!