## ------------------------------------------------------------------- #
## Example 1: Schizophrenia
## ------------------------------------------------------------------- #
data(schizo)
model <- olmm(imps79o ~ tx + sqrt(week) + tx * sqrt(week) + re(1|id), schizo, subset = 1:181)
head(fitted(model))
head(predict(model))
## now make predictions for subject "1103" which is in the learning sample
newdata <- data.frame(id = c("1103", "1103"), tx = c(0, 1), week = c(3, 3))
ranef <- predict(model, type = "ranef")["1103",,drop=FALSE]
## marginal prediction
predict(model, newdata = newdata, type = "response", ranef = FALSE)
## conditional prediction
predict(model, newdata = newdata, type = "response", ranef = ranef)
## conditional prediction with ranef = 0
predict(model, newdata = newdata, type = "response", ranef = ranef * 0)
## predict the response with highest probability
predict(model, newdata = newdata, type = "class")
Run the code above in your browser using DataLab