predict.lrm | R Documentation |
Computes a variety of types of predicted values for fits from
lrm
and orm
, either from the original dataset or for new
observations. The Mean.lrm
and Mean.orm
functions produce
an R function to compute the predicted mean of a numeric ordered
response variable given the linear predictor, which is assumed to use
the first intercept when it was computed. The returned function has two
optional arguments if confidence intervals are desired: conf.int
and the design matrix X
. When this derived function is called
with nonzero conf.int
, an attribute named limits
is attached
to the estimated mean. This is a list with elements lower
and
upper
containing normal approximations for confidence limits
using the delta method.
## S3 method for class 'lrm'
predict(object, ..., type=c("lp", "fitted",
"fitted.ind", "mean", "x", "data.frame",
"terms", "cterms", "ccterms", "adjto","adjto.data.frame",
"model.frame"), se.fit=FALSE, codes=FALSE)
## S3 method for class 'orm'
predict(object, ..., type=c("lp", "fitted",
"fitted.ind", "mean", "x", "data.frame",
"terms", "cterms", "ccterms", "adjto","adjto.data.frame",
"model.frame"), se.fit=FALSE, codes=FALSE)
## S3 method for class 'lrm'
Mean(object, codes=FALSE, ...)
## S3 method for class 'orm'
Mean(object, codes=FALSE, ...)
object |
a object created by |
... |
arguments passed to |
type |
See |
se.fit |
applies only to |
codes |
if |
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. For
Mean.lrm
and Mean.orm
, the result is an R function.
Frank Harrell
Department of Biostatistics
Vanderbilt University
fh@fharrell.com
For the Quantile
function:
Qi Liu and Shengxin Tu
Department of Biostatistics, Vanderbilt University
Hannah M, Quigley P: Presentation of ordinal regression analysis on the original scale. Biometrics 52:771–5; 1996.
lrm
, orm
, predict.rms
,
naresid
, contrast.rms
# See help for predict.rms 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, x=TRUE) #x=TRUE needed for se.fit
# Get 0.95 confidence limits for Prob[better or best]
L <- predict(f, se.fit=TRUE) #omitted kint= so use 1st intercept
plogis(with(L, linear.predictors + 1.96*cbind(-se.fit,se.fit)))
predict(f, type="fitted.ind")[1:10,] #gets Prob(better) and all others
d <- data.frame(x1=c(.1,.5),x2=c(.5,.15))
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
m <- Mean(f, codes=TRUE)
lp <- predict(f, d)
m(lp)
# Can use function m as an argument to Predict or nomogram to
# get predicted means instead of log odds or probabilities
dd <- datadist(x1,x2); options(datadist='dd')
m
plot(Predict(f, x1, fun=m), ylab='Predicted Mean')
# Note: Run f through bootcov with coef.reps=TRUE to get proper confidence
# limits for predicted means from the prop. odds model
options(datadist=NULL)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.