I'm working with survey data of a complex sample to estimate binary outcome models. I am trying to report average marginal effects of a logit model, which I estimated through svyglm
of the survey package in R. However, I get the following error when I use margins
from the package of the same name:
margins(fit, design = lapop) %>% summary()
Error in h(simpleError(msg, call)) : error in evaluating the argument 'object' in selecting a method for function 'summary': arguments imply differing number of rows: 6068, 6054
Seems it is not the summary
function, since the error pops up when executing the margins command with its arguments. I have tried to simply ignore the survey weights at all and shows me equal coefficients and AMEs but not standard errors. Obviously, I cannot present this work by ignoring the survey weights. So I guess what I really need is the standard errors.
I have been reading on the topic and have found no clear solution, I suspect it might have something to do with missing values of the X in the model, but as with any other linear model, R should be just working with complete cases.
I'm not sure if anybody knows anything about this, or if I should simply just report AMEs without standard errors (and thus without p-values). I have uploaded a MWE if anyone is interested, which can be found here.