File: predict.bracl.Rd

package info (click to toggle)
r-cran-brglm2 0.9.2%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 872 kB
  • sloc: ansic: 52; makefile: 5
file content (57 lines) | stat: -rw-r--r-- 2,055 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/bracl.R
\name{predict.bracl}
\alias{predict.bracl}
\title{Predict method for \link{bracl} fits}
\usage{
\method{predict}{bracl}(object, newdata, type = c("class", "probs"), ...)
}
\arguments{
\item{object}{a fitted object of class inheriting from \code{\link[=bracl]{"bracl"}}.}

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

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

\item{...}{further arguments passed to or from other methods.}
}
\value{
If \code{type = "class"} a vector with the predicted response
categories; if \code{type = "probs"} a matrix of probabilities for all
response categories at \code{newdata}.
}
\description{
Obtain class and probability predictions from a fitted adjacent
category logits model.
}
\details{
If \code{newdata} is omitted the predictions are based on the data
used for the fit.
}
\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))

}