[R-sig-ME] Weird problem with augPred()

Viechtbauer, Wolfgang (SP) wo||g@ng@v|echtb@uer @end|ng |rom m@@@tr|chtun|ver@|ty@n|
Thu Feb 28 19:09:45 CET 2019


Hi All,

I came across a weird problem with augPred() from nlme. Here is a reproducible example to illustrate the issue:

library(nlme)

dat <- data.frame(id = c(1,1,1,2,3,3,4,4,4,4),
                  xi = c(1,2,3,1,1,2,1,2,3,4),
                  yi = c(2,1,4,2,3,2,5,4,6,8),
                  zi = c(rep("a",9), NA))

res1 <- lme(yi ~ xi, random = ~ 1 | id, data=dat)
sav1 <- augPred(res1, primary = ~ xi) # WORKS

dat$zi <- "a"

res2 <- lme(yi ~ xi, random = ~ 1 | id, data=dat)
sav2 <- augPred(res2, primary = ~ xi) # WORKS

dat$zi[10] <- NA

res3 <- lme(yi ~ xi, random = ~ 1 | id, data=dat)
sav3 <- augPred(res3, primary = ~ xi) # ERROR

So, if 'zi' is a factor, then a missing value causes no problems (sav1). Or if 'zi' is a character variable without any missings, then augPred() also runs (sav2). But if 'zi' is a character variable and there is at least one missing value, then augPred() fails (sav3).

This aside, why does 'zi' even play a role here? It isn't used at all in the model fit.

Best,
Wolfgang



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