predict: Predict Method for CLM fits

predict.clmR Documentation

Predict Method for CLM fits

Description

Obtains predictions from a cumulative link model.

Usage


## S3 method for class 'clm'
predict(object, newdata, se.fit = FALSE, interval = FALSE,
           level = 0.95,
           type = c("prob", "class", "cum.prob", "linear.predictor"),
           na.action = na.pass, ...)

Arguments

object

a fitted object of class inheriting from clm.

newdata

optionally, a data frame in which to look for variables with which to predict. Note that all predictor variables should be present having the same names as the variables used to fit the model. If the response variable is present in newdata predictions are obtained for the levels of the response as given by newdata. If the response variable is omitted from newdata predictions are obtained for all levels of the response variable for each of the rows of newdata.

se.fit

should standard errors of the predictions be provided? Not applicable and ignored when type = "class".

interval

should confidence intervals for the predictions be provided? Not applicable and ignored when type = "class".

level

the confidence level.

type

the type of predictions. "prob" gives probabilities, "class" gives predicted response class membership defined as highest probability prediction, "cum.prob" gives cumulative probabilities (see details) and "linear.predictor" gives predictions on the scale of the linear predictor including the boundary categories.

na.action

function determining what should be done with missing values in newdata. The default is to predict NA.

...

further arguments passed to or from other methods.

Details

If newdata is omitted and type = "prob" a vector of fitted probabilities are returned identical to the result from fitted.

If newdata is supplied and the response variable is omitted, then predictions, standard errors and intervals are matrices rather than vectors with the same number of rows as newdata and with one column for each response class. If type = "class" predictions are always a vector.

If newdata is omitted, the way missing values in the original fit are handled is determined by the na.action argument of that fit. If na.action = na.omit omitted cases will not appear in the residuals, whereas if na.action = na.exclude they will appear (in predictions, standard errors or interval limits), with residual value NA. See also napredict.

If type = "cum.prob" or type = "linear.predictor" there will be two sets of predictions, standard errors and intervals; one for j and one for j-1 (in the usual notation) where j = 1, ..., J index the response classes.

If newdata is supplied and the response variable is omitted, then predict.clm returns much the same thing as predict.polr (matrices of predictions). Similarly, if type = "class".

If the fit is rank-deficient, some of the columns of the design matrix will have been dropped. Prediction from such a fit only makes sense if newdata is contained in the same subspace as the original data. That cannot be checked accurately, so a warning is issued (cf. predict.lm).

If a flexible link function is used (Aranda-Ordaz or log-gamma) standard errors and confidence intervals of predictions do not take the uncertainty in the link-parameter into account.

Value

A list containing the following components

fit

predictions or fitted values if newdata is not supplied.

se.fit

if se.fit=TRUE standard errors of the predictions otherwise NULL.

upr, lwr

if interval=TRUE lower and upper confidence limits.

Author(s)

Rune Haubo B Christensen

See Also

clm, clmm.

Examples


## simple model:
fm1 <- clm(rating ~ contact + temp, data=wine)
summary(fm1)

## Fitted values with standard errors and confidence intervals:
predict(fm1, se.fit=TRUE, interval=TRUE) # type="prob"
## class predictions for the observations:
predict(fm1, type="class")

newData <- expand.grid(temp = c("cold", "warm"),
                       contact = c("no", "yes"))

## Predicted probabilities in all five response categories for each of
## the four cases in newData:
predict(fm1, newdata=newData, type="prob")
## now include standard errors and intervals:
predict(fm1, newdata=newData, se.fit=TRUE, interval=TRUE, type="prob")



runehaubo/ordinal documentation built on Dec. 12, 2023, 1:09 p.m.