rms.trans {rms} | R Documentation |
This is a series of functions (asis
, pol
, lsp
, rcs
, catg
,
scored
, strat
, matrx
, and %ia%
) that set up special attributes
(such as
knots and nonlinear term indicators) that are carried through to fits
(using for example lrm
,cph
, ols
, psm
). anova.rms
, summary.rms
,
Predict
, survplot
, fastbw
, validate
, specs
,
which.influence
, nomogram
and latex.rms
use these
attributes to automate certain analyses (e.g., automatic tests of linearity
for each predictor are done by anova.rms
). Many of the functions
are called implicitly. Some S functions such as ns
derive data-dependent
transformations that are not "remembered" when predicted values are
later computed, so the predictions will be incorrect. The functions listed
here solve that problem.
asis
is the identity transformation, pol
is an ordinary (non-orthogonal) polynomial, rcs
is
a linear tail-restricted cubic spline function (natural spline, for which the
rcspline.eval
function generates the design matrix and the
presence of system option rcspc
causes rcspline.eval
to be
invoked with pc=TRUE
),
catg
is for a categorical
variable, scored
is for an ordered categorical
variable, strat
is for a stratification factor
in a Cox model, matrx
is for a matrix predictor, and %ia%
represents
restricted interactions in which products involving nonlinear effects on both
variables are not included in the model. asis, catg, scored, matrx
are seldom invoked
explicitly by the user (only to specify label
or name
, usually).
In the list below, functions asis
through strat
can have
arguments x, parms, label, name
except that parms
does not
apply to asis, matrx, strat
.
asis(\dots) matrx(\dots) pol(\dots) lsp(\dots) rcs(\dots) catg(\dots) scored(\dots) strat(\dots) %ia%(x1, x2)
asis(x, parms, label, name) matrx(x, label, name) pol(x, parms, label, name) lsp(x, parms, label, name) rcs(x, parms, label, name) catg(x, parms, label, name) scored(x, parms, label, name) strat(x, label, name) x1 %ia% x2
x |
a predictor variable (or a function of one). If you specify e.g.
|
parms |
parameters of transformation (e.g. number or location of knots).
For |
label |
label of predictor for plotting (default = |
name |
Name to use for predictor in model. Default is name of argument to function |
x1,x2 |
two continuous variables for which to form a non-doubly-nonlinear interaction |
... |
a variety of things |
Frank Harrell
Department of Biostatistics, Vanderbilt University
f.harrell@vanderbilt.edu
rcspline.eval
, rcspline.restate
, rms
, cph
, lrm
, ols
, datadist
## Not run: options(knots=4, poly.degree=2) country <- factor(country.codes) blood.pressure <- cbind(sbp=systolic.bp, dbp=diastolic.bp) fit <- lrm(Y ~ sqrt(x1)*rcs(x2) + rcs(x3,c(5,10,15)) + lsp(x4,c(10,20)) + country + blood.pressure + poly(age,2)) # sqrt(x1) is an implicit asis variable, but limits of x1, not sqrt(x1) # are used for later plotting and effect estimation # x2 fitted with restricted cubic spline with 4 default knots # x3 fitted with r.c.s. with 3 specified knots # x4 fitted with linear spline with 2 specified knots # country is an implied catg variable # blood.pressure is an implied matrx variable # since poly is not an rms function (pol is), it creates a # matrx type variable with no automatic linearity testing # or plotting f1 <- lrm(y ~ rcs(x1) + rcs(x2) + rcs(x1) %ia% rcs(x2)) # %ia% restricts interactions. Here it removes terms nonlinear in # both x1 and x2 f2 <- lrm(y ~ rcs(x1) + rcs(x2) + x1 %ia% rcs(x2)) # interaction linear in x1 f3 <- lrm(y ~ rcs(x1) + rcs(x2) + x1 %ia% x2) # simple product interaction (doubly linear) # Use x1 %ia% x2 instead of x1:x2 because x1 %ia% x2 triggers # anova to pool x1*x2 term into x1 terms to test total effect # of x1 ## End(Not run)