[R-sig-ME] use.u argument in bootMer in lme4a

joris.dewolf at cropdesign.com joris.dewolf at cropdesign.com
Thu Dec 30 17:39:54 CET 2010


Hi,

I am trying out the function bootMer in lme4a (lme4a_0.999375-59), 
specifically the option whether or not to bootstrap the random effects and 
stumbled on a couple of problems.

The documentation says:
bootMer(x, FUN, nsim=1, seed, use.u=FALSE, verbose=FALSE, control=list())
use.u: logical, indicating, if the spherized random effects should be 
simulated / bootstrapped as well. If FALSE, they are not changed, and all 
inference is conditional on these.

I interpret this as if the argument 'use.u' is FALSE, the random effects 
are not simulated.

Applying this on my model with call 
lmer(value ~ transgenity + (transgenity | event))

(the merMod object is given in attach), I get the following:

load("modL1.2.obj")
params <- function(m) {
        VC <- VarCorr(m)$event
        c(beta =m at fe@coef, sigma = sigma(m),
                sig01 = sqrt(VC[1,1]), sig02 = sqrt(VC[2,2]),sig03 = VC[1,
2])
}
bs.uF <- bootMer(modL1.2, params, nsim = 3,use.u = FALSE)

[no warnings nor errors, output looks fine]

bs.uT <- bootMer(modL1.2, params, nsim = 3,use.u = TRUE)
Warning messages:
1: In (if (use.u) u else as.vector(U %*% rnorm(q))) + rnorm(n) :
  longer object length is not a multiple of shorter object length
2: In (if (use.u) u else as.vector(U %*% rnorm(q))) + rnorm(n) :
  longer object length is not a multiple of shorter object length
3: In (if (use.u) u else as.vector(U %*% rnorm(q))) + rnorm(n) :
  longer object length is not a multiple of shorter object length

[only this warning, output looks fine as well]

In order to understand the warning, I checked the function bootMer from 
which I reproduced two pieces of code.


snippet1:
    if (use.u) {
        u <- x at re@u
    }
    else {
        U <- crossprod(x at re@Zt, x at re@Lambda)
        q <- ncol(U)
    }

snippet2

        y <- {
            X.beta + sigm.x * ((if (use.u) 
                u
            else as.vector(U %*% rnorm(q))) + rnorm(n))
        }

My two questions are:

1. From snippet 2, it seems to me that if(use.u) == TRUE, the random 
effects are NOT bootstrapped, contrary to what the documentation says. 
2. u has indeed wrong dimensions. Would 
u <- crossprod(x at re@Zt, x at re@u)
be the correct definition of u? 


Thanks.
Joris







> sessionInfo()
R version 2.12.0 (2010-10-15)
Platform: i386-pc-mingw32/i386 (32-bit)

locale:
[1] LC_COLLATE=Dutch_Belgium.1252  LC_CTYPE=Dutch_Belgium.1252 
[3] LC_MONETARY=Dutch_Belgium.1252 LC_NUMERIC=C 
[5] LC_TIME=Dutch_Belgium.1252 

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base 

other attached packages:
 [1] boot_1.2-43        TeachingDemos_2.7  coda_0.14-2 lme4a_0.999375-59 
 [5] MatrixModels_0.2-1 minqa_1.1.13       Rcpp_0.8.9 Matrix_0.999375-46
 [9] lattice_0.19-13    RODBC_1.3-2        gtools_2.6.2       rj_0.5.0-5   
 

loaded via a namespace (and not attached):
[1] codetools_0.2-2 grid_2.12.0     nlme_3.1-97     rJava_0.8-8 
[5] splines_2.12.0  stats4_2.12.0   tools_2.12.0 
 


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