You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Thank you for the excellent package! I think there may be a bug in (g)lmer models with non-linear functions of predictors.
Here is a minimal reproducible example:
library("margins")
library("lme4")
fm1 <- lmer(Reaction ~ ns(Days,2) + (Days|Subject), sleepstudy)
margins(fm1)
Error in data.table::rbindlist(list(d0, d1)) :
Column 1 of item 1 is length 180 inconsistent with column 2 which is length 360. Only length-1 columns are recycled.
The same error occurs if I use splines::ns in the model formula instead of ns. The same issue happens using stats::poly instead of splines::ns, but not using log(Days+1) instead of ns(Days,2). However ns, poly, etc. functionality does work for lm models in margins, which makes me think this may be a bug?
In case anyone else has this issue -- I think an equivalent manual workaround is to use marginal_effects (which works), then take column means. For the example above:
Please specify whether your issue is about:
Thank you for the excellent package! I think there may be a bug in
(g)lmer
models with non-linear functions of predictors.Here is a minimal reproducible example:
The same error occurs if I use
splines::ns
in the model formula instead ofns
. The same issue happens usingstats::poly
instead ofsplines::ns
, but not usinglog(Days+1)
instead ofns(Days,2)
. Howeverns
,poly
, etc. functionality does work forlm
models inmargins
, which makes me think this may be a bug?Session info and traceback:
The text was updated successfully, but these errors were encountered: