Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

predict.bracl

Predict method for bracl fits


Description

Obtain class and probability predictions from a fitted adjacent category logits model.

Usage

## S3 method for class 'bracl'
predict(object, newdata, type = c("class", "probs"), ...)

Arguments

object

a fitted object of class inheriting from "bracl".

newdata

optionally, a data frame in which to look for variables with which to predict. If omitted, the fitted linear predictors are used.

type

the type of prediction required. The default is "class", which produces predictions of the response category at the covariate values supplied in "newdata", selecting the category with the largest probability; the alternative "probs" returns all category probabilities at the covariate values supplied in "newdata".

...

further arguments passed to or from other methods.

Details

If newdata is omitted the predictions are based on the data used for the fit.

Value

If type = "class" a vector with the predicted response categories; if type = "probs" a matrix of probabilities for all response categories at newdata.

Examples

data("stemcell", package = "brglm2")

# Adjacent category logit (non-proportional odds)
fit_bracl <- bracl(research ~ as.numeric(religion) + gender, weights = frequency,
                   data = stemcell, type = "ML")
# Adjacent category logit (proportional odds)
fit_bracl_p <- bracl(research ~ as.numeric(religion) + gender, weights = frequency,
                    data = stemcell, type = "ML", parallel = TRUE)

# New data
newdata <- expand.grid(gender = c("male", "female"),
                       religion = c("liberal", "moderate", "fundamentalist"))

# Predictions
sapply(c("class", "probs"), function(what) predict(fit_bracl, newdata, what))
sapply(c("class", "probs"), function(what) predict(fit_bracl_p, newdata, what))

brglm2

Bias Reduction in Generalized Linear Models

v0.7.1
GPL-3
Authors
Ioannis Kosmidis [aut, cre] (<https://orcid.org/0000-0003-1556-0302>), Kjell Konis [ctb], Euloge Clovis Kenne Pagui [ctb], Nicola Sartori [ctb]
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.