Description Usage Arguments Details Author(s) Examples
Plots a specialized radar (aka, ‘star’) plot to compare summary statistics on a handful of covariates, across a multi-dimensional set of comparison groups, as in the standard ‘Table 1’ of experimental studies, where the groups correspond to treatment assignments.
1 2 3 4 |
x |
Typically, a formula of the form |
data |
Either a |
datadist |
An |
xlim |
A positioning parameter that really should be automated! |
ylim |
A positioning parameter that really should be automated! |
rescale |
How to rescale continuous covariates for plotting on the spokes |
treatment |
When |
stratify |
When |
strength |
When the default choice of strength-of-association measure is not suitable, it may be specified explicitly as a named vector with elements corresponding to the spoke variables, in the order they appear in the model formula. The names will be printed at the outer endpoints of the spokes, and will typically be numbers (e.g., odds ratios) rounded to 2-3 significant figures. |
include.na |
Should the summary include NA values? Passed to the summary.formula call that generates the radarplot data. |
overall |
Should the summary include an 'ALL' row? Passed to the summary.formula call that generates the radarplot data. |
... |
Other parameters to be passed to |
The covariates appear on the radii, or 'spokes' of the radarplot,
while the several (up to 3) dimensions defining the comparison
groups appear as a color-coded overlay, plus up to two trellis
dimensions. In generic applications, the client code employs
Hmisc::summary.formula(method='cross')
to create the
multi-dimensional array for plotting, and then rescales the array
elements by a linear or affine transformation to the interval
[0,1]. Ordered factors may be treated as quasi-continuous
variables according to their internal integer representation;
logical covariates (and also, conveniently, 2-valued factors)
appear as proportions; and unordered categorical variables with n
levels may be transformed to n-1 dummy variables, which may then
be plotted as proportions. An optional strength
parameter
may be specified, providing a strength-of-association measure
connecting the spoke variables to the experimental outcome. This
is reflected graphically by fanning the spokes out into sectors
subtending angles proportional to the strength of associations.
Used in this way, the radar plot draws attention to those spoke
variables with greatest potential to confound the outcome, and so
becomes a useful exploratory tool. To provide convenient support
for this specialized usage, radarplot
optionally accepts a
regression model in which the outcome of interest is the
regressand, and the spoke variables are regressors. From this
model, strength-of-association measures are automatically derived,
appropriately to the class of the regression model. Invoked in
this way, radarplot
is also able to free client code from
the burden of generating and rescaling a summary.formula.cross
object. At this time, models of class lrm
and cph
are
supported. See the example code below.
David C. Norris
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 | library(rms)
df <- upData(mtcars,
#cyl=factor(cyl,levels=2*(2:4),labels=paste(2*(2:4),"cyl", sep="-")),
#am=factor(am,levels=0:1,labels=c("automatic","manual")),
#gear=factor(gear,levels=3:5,labels=paste(3:5,"speed", sep="-")),
labels=c(
mpg="Miles per gallon"
,cyl="Number of cylinders"
,disp="Displacement"
,hp="Gross horsepower"
,drat="Rear axle ratio"
,wt="Weight"
,qsec="1/4 mile time"
,am="Transmission type"
,gear="Number of forward gears"
,carb="Number of carburetors"
),
units=c(
wt="lb/1000"
,disp="in^3"
,qsec="sec"
),
drop='vs'
)
df$cyl <- factor(df$cyl,levels=2*(2:4),labels=paste(2*(2:4),"cyl", sep="-"))
df$am <- factor(df$am,levels=0:1,labels=c("automatic","manual"))
df$gear<- factor(df$gear,levels=3:5,labels=paste(3:5,"speed", sep="-"))
s <- summary(cbind(mpg, disp, hp, drat, wt) ~ cyl + gear + am,
method='cross', overall=TRUE, data=df)
dd <- datadist(df)
radarplot(S ~ cyl | gear*am, data=s, datadist=dd, rescale="range")
## TODO: Provide example of convenient usage with 'lrm' and 'cph' models.
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.