first, thanks for putting together and maintaining this package - would be difficult to work without it!
A possible bug: I have an issue with getting marginal effects from a linear mixed model that is estimated with lmerTest::lmer() (the same with lme4::lmer()) and which includes nested random effects.
To give an example:
library(lmerTest)
library(margins)
# Example data: 96 students clustered in 10 schools
mlmdata <- haven::read_dta("https://stats.idre.ucla.edu/stat/examples/imm/imm10.dta")
# Factor variable used below for nested random effects:
mlmdata$parented_fac <- as.factor(mlmdata$parented)
Error in levelfun(r, n, allow.new.levels = allow.new.levels) :
new levels detected in newdata
I get the same issue when I work with my actual data (which I cannot share at the moment). I also get the same issue when I try to get margins from an interactive model with at().
Dear Thomas,
first, thanks for putting together and maintaining this package - would be difficult to work without it!
A possible bug: I have an issue with getting marginal effects from a linear mixed model that is estimated with lmerTest::lmer() (the same with lme4::lmer()) and which includes nested random effects.
To give an example:
This, without nesting, works:
This, with nesting, does not:
The error I get is:
I get the same issue when I work with my actual data (which I cannot share at the moment). I also get the same issue when I try to get margins from an interactive model with at().
traceback()
SessionInfo()
I hope you can help! Many thanks in any case for your time!
Best, Carlo