averageObs fails when lmer has weights specified
hrlai opened this issue · comments
Hi @jknowles , I fitted a lmer
model with weights
and could not get merTools::averageObs
to work. The following example
m1 <- lmer(Reaction ~ Days + (1 | Subject), sleepstudy, weights = Days)
averageObs(m1)
should return:
Number of observations < 20, random effect quantiles may not be well-defined.
Error in `[.data.frame`(out, , names(merMod@frame)) :
undefined columns selected
Is it because there is now an additional column name in names(m1@frame)
called (weights)
? Thanks for your attention in advance.
Yes - I think that is the issue exactly. I should be able to patch this relatively easily. Thank you for providing a reproducible example.
The dev version now at the master branch of this repository should solve this for you @hrlai thanks again for the bug report. Feel free to test and reopen if the issue recurs.
Thanks for patching @jknowles but the latest dev release still seems to be ver0.5.0? Running install_github("jknowles/merTools")
returns ─ building ‘merTools_0.5.0.tar.gz’
but I see in NEWS
that this is fixed in v0.5.1...
Does the issue still occur? @hrlai I forgot to bump the version number after I made the patch. So even though the version number is the same, the code is different and should handle the weights.
It works!
Thanks for checking in, I should've run it earlier but good to know it's just that the version number hasn't been updated. All good.
Sorry for the confusion @hrlai - glad it works. Thank you for the excellent bug report to help me catch this. I'll probably push these and some additional changes to CRAN in the late spring.