r - glmer prediction with allow.new.levels=TRUE -


i have looked @ prediction lme4 on new levels r documentation quoted allow.new.levels=true.

i dont understand "if allow.new.level=true, prediction use unconditional (population-level) values data unobserved levels (or nas)" means.

in case have data.frame called exdata

 subjects y        x1         x2    1 0 1.6179339  0.9517194    1 0 1.4128789  1.0248514    1 0 0.9127448  1.8073684    1 0 1.5729219  2.1003925    1 0 1.6254359  1.2471660    2 0 1.6626074  8.5102559    2 0 1.3903638  6.0425018    2 0 1.1438239  2.5654422    2 0 1.1393088  2.9982242    2 0 1.1564141  2.8395960    3 0 1.1688192 13.9791461    3 0 0.9255715 18.8544778    3 0 1.2369097  4.2376671    3 0 1.3021943  9.6894289    3 0 1.2296961 12.4789910    4 0 1.0978131  2.0577688    4 0 1.1405409  1.4339044    4 0 1.0355546  1.9496732    4 0 1.1370849  1.7402332    4 0 1.1942591  1.3509880    5 0 0.4141535  2.1723957    5 0 0.9129311  0.8274350    5 0 0.9658796  1.2754419    5 0 0.8370701  2.1998756    5 0 0.5509546  2.3590774    6 0 1.2827411  1.5474088    6 0 1.1636606  0.7746669    6 0 1.1782936  1.1566909    6 0 1.1630238  1.7486415    6 0 1.1565711  0.6984409    7 0 0.8600331  0.1382253    7 0 0.8303510  0.1927431    7 0 0.8087967  0.6065926    7 0 0.7815187  0.9464185    7 0 0.7532042  0.9771646    8 0 1.1638190  1.3456340    8 0 0.5867126  1.4862727    8 0 0.6523964  0.5138441    8 0 0.9513971  2.3932337    8 0 0.9278743  2.3273670    9 1 1.0978606  1.2585635    9 1 1.0414897  1.2946008    9 0 0.6215353  0.2907148    9 0 1.0267046  1.0173432    9 0 1.1470992  0.7014759   10 0 0.9505266  0.4247866   10 0 0.8624758  0.2276577   10 0 0.8279061  0.2314898   10 0 0.7856832  0.3143003   10 0 0.7569739  0.7880622 

with 10 subjects, y response (0-1) , 2 explanatory variables. want model logit glm random effect model, use

model <- glmer(y~x1+x2+ (1|subjects), family=binomial(link="logit"), data=exdata[exdata$subjects!=5,], nagq=1) 

i use first 4 subjects want use last 1 prediction. result of model variance of random effect on 82.55 , estimates

(intercept) -14.8377 x1            4.0366 x2            0.1056 

the prediction new subject is

prediction <- predict(model, newdata=exdata[exdata$subjects==5,], type="response", allow.new.levels=true) 

giving

2.408299e-06 1.564704e-05 2.031392e-05 1.331586e-05 4.266690e-06 

how these values predicted? hope ranef() subject=5 calculated, , coefficients model used calculate proability. can in way print ranef() of subject=5?. dont understand r documentation allow.new.levels cant understand how prediction made.

in specific example fixed part of model used (since population-level model model single random effect):

y1 <- as.matrix(cbind(1, exdata[exdata$subjects==5, c("x1", "x2")])) %*% fixef(model)  c(exp(y1)/(1+exp(y1))) #[1] 2.408298e-06 1.564704e-05 2.031392e-05 1.331586e-05 4.266689e-06 

Comments