New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Error when using margins after lmer #56
Comments
|
This is not currently supported. If you want to poke around and make some suggestions on lmer support, I'm open to it. |
|
I think this should be working now: library("lme4")
m <- lmer(Reaction~Days+(1|Subject), data=sleepstudy)
(mar <- margins(m))
## Average marginal effects
## Days
## 10.47
## Warning message:
## In marginal_effects.merMod(model = model, data = data, type = type, :
## factor variables are not handled as factor for models of class 'merMod'
summary(mar)
## factor AME SE z p lower upper
## Days 10.4673 NA NA NA NA NA |
|
I've gotten the following error when using margins on a random intercept model (1 | location) with v 0.3.5 |
|
@jeffmax Ah, sorry. Apparently the |
|
@leeper, I am still getting the same error (confirmed help says 0.3.6). Thanks for looking into this so fast. |
|
@jeffmax what's the class of the object you're passing to margins()? |
|
|
@jeffmax Can you try to make a reproducible example? The package works with examples from |
|
Hi @leeper, I am having the exact same issue. I re-downloaded margins from Github and continue to have the follow error as well even when I use the sleep study dataset. Thank you so much for all your work on this package! |
|
Hi @leeper, this seems to be an awesome package. Much appreciate your work on this! |
|
yeh @leeper it is really great to see this package because it can get us average marginal effects. Please share if you have any updates. I am getting similar Error message |
|
With the latest Github versions of I do get (for model and (for model But at first glance these warnings are more or less spurious in terms of their bearing on the accuracy of the output. |
|
The latest version on Github seems to have regressed from when @jacob-long commented. MWE: and the output |
|
Thanks all for your bug reports. I'm about to push an update that will include much more extensive unit testing for mixed effects models so that we shouldn't encounter these regression issues again. I believe all of these examples will now run successfully. Let me know if not. |
|
I noticed that the message library("lme4")
#> Loading required package: Matrix
library("margins")
sleepstudy2 <- sleepstudy
set.seed(1)
sleepstudy2$logical <- sample(c(TRUE, FALSE), nrow(sleepstudy2), replace = TRUE)
m <- lmer(Reaction ~ Days + logical + (1 | Subject), data = sleepstudy2)
(mar <- margins(m))
#> Warning in predict.merMod(model, newdata = out, type = type, re.form =
#> re.form, : unused arguments ignored
#> Warning in predict.merMod(model, newdata = out, type = type, re.form =
#> re.form, : unused arguments ignored
#> Warning in predict.merMod(model, newdata = out, type = type, re.form =
#> re.form, : unused arguments ignored
#> Warning in predict.merMod(model, newdata = out, type = type, re.form =
#> re.form, : unused arguments ignored
#> Warning in predict.merMod(model, newdata = out, type = type, re.form =
#> re.form, : unused arguments ignored
#> Average marginal effects
#> Days logical
#> 10.28 -8.464The warning disappears when the logical variable is converted to Created on 2021-01-29 by the reprex package (v1.0.0) |
I'm not sure what sort of shape the lme4 support is supposed to be in yet so apologies if premature, but I've hit a bug which I thought I'd share:
produces: this error:
After poking around a little:
Produces:
Which is referring to something here https://github.com/leeper/margins/blob/f44c149465d0497175a878d9e8db17c135632c2f/R/delta.R
The text was updated successfully, but these errors were encountered: