Skip to content

predict() with varying betas (newparams)

1 message · Hans Ekbrand

#
Perhaps it is well-known to you, but I noticed that using re.form = NA
gives exactly the same results as when using newparams

mean(predict(my.fit, newdata = my.fit at frame, type = "response",
		     newparams = list(theta = my.fit at theta, beta = my.fit at beta)))

theta parameter vector not named: assuming same order as internal vector
beta parameter vector not named: assuming same order as internal vector
[1] 0.05619105
mean(predict(my.fit, newdata = my.fit at frame, type = "response", re.form = NA))
[1] 0.05619105

Or, when using your reproducible example (thanks for that, BTW)

gm1 <- glmer(cbind(incidence, size - incidence) ~ period + (1 | herd),
       			     data = cbpp, family = binomial)

identical(mean(p1 <- predict(gm1, re.form=NA)), mean(p1 <-
predict(gm1,newdata=model.frame(gm1), newparams=list(beta=fixef(gm1),
theta = gm1 at theta))))
theta parameter vector not named: assuming same order as internal vector
[1] TRUE