Matchthem and Marginal Effects with multiply imputed data

34 views Asked by At

I am working on a PSM model with multiply imputed data. I am trying to get the marginal effects for the estimates. I can easily get the pooled logistic regression model, but I cannot seem to the marginal effects. I am attaching my code for any assistance. I am new to the marginal effects function, but I need this in the context of Matchthem. Any assistance will be welcomed, and here is the code:

library(mice) 
library(MatchThem) 
library(cobalt)
library(survey)
library(marginaleffects)

data('osteoarthritis')

summary(osteoarthritis)

imputed.datasets<-mice(osteoarthritis,m=5)

matched.datasets<-matchthem(OSP~AGE+SEX+BMI+RAC+SMK, 
                            datasets=imputed.datasets, 
                            approach='within', 
                            method='full', 
                            distance = 'glm', 
                            link = 'logit')

bal.tab(matched.datasets,stats=c('m','ks'), imp.fun='max', abs=TRUE)

matched.models<-with(matched.datasets, 
                     svyglm(KOA~OSP,family=quasibinomial()), 
                     cluster=TRUE)

matched.results<-pool(matched.models)
summary(matched.results,conf.int=TRUE)
summary(matched.results,conf.int=TRUE, exponentiate = TRUE)


comp.imp <- lapply(matched.datasets, function(fit) {
  avg_comparisons(fit, newdata = subset(fit$matched.datasets, 'OSP' == 1),
                  variables = "OSP", wts = "weights", vcov = "HC3"
  )
})

pooled.comp <- mice::pool(comp.imp)

I am sure it is something I am just overlooking.

0

There are 0 answers