predict.lrm {Design} | R Documentation |
Computes a variety of types of predicted values for fits from
lrm
, either from the original dataset or for new observations.
## S3 method for class 'lrm': predict(object, ..., type=c("lp", "fitted", "fitted.ind", "mean", "x", "data.frame", "terms", "adjto","adjto.data.frame", "model.frame"), se.fit=FALSE, codes=FALSE)
object |
a object created by lrm
|
... |
arguments passed to predict.Design , such as kint and newdata
(which is used if you are predicting out of data ). See
predict.Design to see how NAs are handled.
|
type |
See predict.Design for "x", "data.frame", "terms", "adjto",
"adjto.data.frame" and "model.frame" . type="lp" is used to get
linear predictors (always using the first intercept). type="fitted"
is used to get all the probabilities Y>=q
j. type="fitted.ind" gets all the individual probabilities
Y=j. For an ordinal response variable, type="mean" computes
the estimated mean Y by summing values of Y
multiplied by the estimated Prob(Y=j). If Y was a character or
factor object, the levels are the character values or factor levels,
so these must be translatable to numeric, unless codes=TRUE .
See the Hannah and Quigley reference below for the method of estimating
(and presenting) the mean score. If you specify
type="fitted","fitted.ind","mean" you may not specify kint .
|
se.fit |
applies only to type="lp" , to get standard errors.
|
codes |
if TRUE , type="mean" uses the integer codes
1,2,...,k for the k-level response in computing the
predicted mean response.
|
a vector (type="lp"
with se.fit=FALSE
, or type="mean"
or only one
observation being predicted), a list (with elements linear.predictors
and se.fit
if se.fit=TRUE
), a matrix (type="fitted"
or type="fitted.ind"
),
a data frame, or a design matrix.
Frank Harrell
Department of Biostatistics
Vanderbilt University
f.harrell@vanderbilt.edu
Hannah M, Quigley P: Presentation of ordinal regression analysis on the original scale. Biometrics 52:771–5; 1996.
lrm
, predict.Design
, naresid
, contrast.Design
# See help for predict.Design for several binary logistic # regression examples # Examples of predictions from ordinal models set.seed(1) y <- factor(sample(1:3, 400, TRUE), 1:3, c('good','better','best')) x1 <- runif(400) x2 <- runif(400) f <- lrm(y ~ rcs(x1,4)*x2) predict(f, type="fitted.ind")[1:10,] #gets Prob(better) and all others d <- data.frame(x1=.5,x2=.5) predict(f, d, type="fitted") # Prob(Y>=j) for new observation predict(f, d, type="fitted.ind") # Prob(Y=j) predict(f, d, type='mean', codes=TRUE) # predicts mean(y) using codes 1,2,3