plot.xmean.ordinaly {Design} | R Documentation |
Separately for each predictor variable X in a formula, plots the mean of X vs. levels of Y. Then under the proportional odds assumption, the expected value of the predictor for each Y value is also plotted (as a dotted line). This plot is useful for assessing the ordinality assumption for Y separately for each X, and for assessing the proportional odds assumption in a simple univariable way. If several predictors do not distinguish adjacent categories of Y, those levels may need to be pooled. This display assumes that each predictor is linearly related to the log odds of each event in the proportional odds model. There is also an option to plot the expected means assuming a forward continuation ratio model.
plot.xmean.ordinaly(x, data, subset, na.action, subn=TRUE, cr=FALSE, ...)
x |
an S formula. Response variable is treated as ordinal. Predictor variables must be binary or continuous. Interactions or non-linear effects are not allowed. |
data |
a data frame or frame number |
subset |
vector of subscripts or logical vector describing subset of data to analyze |
na.action |
defaults to na.keep so all NAs are initially retained. Then NAs
are deleted only for each predictor currently being plotted.
Specify na.action=na.delete to remove observations that are missing
on any of the predictors (or the response).
|
subn |
set to FALSE to suppress a left bottom subtitle specifying the sample size
used in constructing each plot
|
cr |
set to TRUE to plot expected values by levels of the response, assuming a
forward continuation ratio model holds. The function is fairly slow
when this option is specified.
|
... |
other arguments passed to plot and lines
|
plots
Frank Harrell
Department of Biostatistics
Vanderbilt University
f.harrell@vanderbilt.edu
Harrell FE et al. (1998): Development of a clinical prediction model for an ordinal outcome. Stat in Med 17:909–44.
lrm
, residuals.lrm
, cr.setup
, cumcategory
# Simulate data from a population proportional odds model set.seed(1) n <- 400 age <- rnorm(n, 50, 10) blood.pressure <- rnorm(n, 120, 15) L <- .2*(age-50) + .1*(blood.pressure-120) p12 <- plogis(L) # Pr(Y>=1) p2 <- plogis(L-1) # Pr(Y=2) p <- cbind(1-p12, p12-p2, p2) # individual class probabilites # Cumulative probabilities: cp <- matrix(cumsum(t(p)) - rep(0:(n-1), rep(3,n)), byrow=TRUE, ncol=3) y <- (cp < runif(n)) %*% rep(1,3) # Thanks to Dave Krantz <dhk@paradox.psych.columbia.edu> for this trick par(mfrow=c(1,2)) plot.xmean.ordinaly(y ~ age + blood.pressure, cr=TRUE) par(mfrow=c(1,1))