[R-sig-ME] Bug in lme4: attr(mod at frame, "na.action") is not re-initialized to NULL

Steve Walker steve.walker at utoronto.ca
Tue Mar 11 21:16:28 CET 2014


This seems to work:

refit(mod, simulate(mod, na.action = na.exclude))

Cheers,
Steve

On 3/11/2014, 3:51 PM, Alexandre Courtiol wrote:
> I think I found a bug... and it may affect several versions of lmer (but I
> did not try the one before 1.0).
> The bug is that the attribute na.action of the model frame is not
> re-initialized to NULL (both in lmer and glmer).
>
> example:
>
> data <- data.frame(y=rnorm(100), K=factor(rep(1:10,10)))
> data[3, "y"] <- NA
> library(lme4)
> mod <- lmer(y~1+(1|K), data=data)
> dim(mod at frame) # 99 2 The model frame has excluded the line as it should
> attr(mod at frame, "na.action") # 3 The value 3 is still considered missing
> while it should not
>
> This feature is slightly annoying because it creates the function refit to
> crash and others using refit (I came to discover that from a crash in
> PBmodcomp from pbkrtest)...
>
> example:
>
> refit(mod, simulate(mod)) # CRASH
> attr(mod at frame,"na.action") <- NULL # fast and dirty patch...
> refit(mod, simulate(mod)) # works
>
> Thanks to the lmer team for your great work!
> PS: If you don't see that as a bug, please send an informative warning.
>
>
>
>> sessionInfo()
> R version 3.0.2 (2013-09-25)
> Platform: x86_64-pc-linux-gnu (64-bit)
>
> attached base packages:
> [1] parallel  stats     graphics  grDevices utils     datasets  methods
> [8] base
>
> other attached packages:
> [1] pbkrtest_0.3-8 MASS_7.3-29    lme4_1.1-4     Rcpp_0.11.0
> Matrix_1.1-2
>
> loaded via a namespace (and not attached):
> [1] grid_3.0.2          lattice_0.20-27     minqa_1.2.3
> [4] nlme_3.1-113        RcppEigen_0.3.2.0.3 splines_3.0.2
> [7] tools_3.0.2
>



More information about the R-sig-mixed-models mailing list