Learn R Programming

vcrpart (version 0.2-1)

olmm-predict: Predict outcome probabilities and responses for olmm objects

Description

fitted and predict method for olmm objects.

Usage

## S3 method for class 'olmm':
fitted(object, ...)

## S3 method for class 'olmm': predict(object, newdata = NULL, type = c("link", "response", "prob", "class", "ranef"), ranef = FALSE, na.action = na.pass, ...)

Arguments

object
a fitted olmm object.
newdata
data frame for which to evaluate predictions.
type
character string. type = "response" and type = "prob" yield response probabilities, type = "class" the response category with highest probability and type = "link" the linear predictor
ranef
logical or numeric matrix. For all of type = "response", type = "prob" or type = "class", the option ranef = FALSE yields the marginal outcome probabilities resp. outcomes with highest margin
na.action
function determining what should be done with missing values for fixed effects in newdata. The default is to predict NA: see na.pass.
...
optional additional parameters. Includes offset and subset.

Value

  • A matrix or a vector of predicted values or response probabilities.

See Also

olmm, olmm-methods

Examples

Run this code
## ------------------------------------------------------------------- #
## 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