Learn R Programming

ordinal (version 2010.03-04)

predict.clm: Predict Method for CLM fits

Description

Obtains predictions from a cumulative link model.

Usage

## S3 method for class 'clm':
predict(object, newdata, ...)

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.
...
further arguments passed to or from other methods.

Value

  • A vector of predicted probabilities.

See Also

clm.

Examples

Run this code
options(contrasts = c("contr.treatment", "contr.poly"))
data(soup)

## More manageable data set for less voluminous printing:
(tab26 <- with(soup, table("Product" = PROD, "Response" = SURENESS)))
dimnames(tab26)[[2]] <- c("Sure", "Not Sure", "Guess", "Guess", "Not Sure", "Sure")
dat26 <- expand.grid(sureness = as.factor(1:6), prod = c("Ref", "Test"))
dat26$wghts <- c(t(tab26))
dat26

m1 <- clm(sureness ~ prod, scale = ~prod, data = dat26,
          weights = wghts, link = "logistic")
predict(m1)

mN1 <-  clm(sureness ~ 1, nominal = ~prod, data = dat26,
            weights = wghts)
predict(mN1)

predict(update(m1, scale = ~.-prod))

## Fit model from polr example:
data(housing, package = "MASS")
fm1 <- clm(Sat ~ Infl + Type + Cont, weights = Freq, data = housing)
predict(fm1)

Run the code above in your browser using DataLab