rcspline.eval {Hmisc} | R Documentation |
Computes matrix that expands a single variable into the terms needed to
fit a restricted cubic spline (natural spline) function using the
truncated power basis. Two normalization options are given for somewhat
reducing problems of ill-conditioning. The antiderivative function can
be optionally created. If knot locations are not given, they will be
estimated from the marginal distribution of x
.
rcspline.eval(x, knots, nk=5, inclx=FALSE, knots.only=FALSE, type="ordinary", norm=2, rpm=NULL, pc=FALSE)
x |
a vector representing a predictor variable |
knots |
knot locations. If not given, knots will be estimated using default
quantiles of |
nk |
number of knots. Default is 5. The minimum value is 3. |
inclx |
set to |
knots.only |
return the estimated knot locations but not the expanded matrix |
type |
|
norm |
|
rpm |
If given, any NAs in |
pc |
Set to |
If knots.only=TRUE
, returns a vector of knot locations. Otherwise returns
a matrix with x
(if inclx=TRUE
) followed by nk-2
nonlinear terms.
The matrix has an attribute knots
which is the vector of knots
used. When pc
is TRUE
, an additional attribute is stored:
pcparms
, which contains the center
and scale
vectors and the rotation
matrix.
Devlin TF and Weeks BJ (1986): Spline functions for logistic regression modeling. Proc 11th Annual SAS Users Group Intnl Conf, p. 646–651. Cary NC: SAS Institute, Inc.
x <- 1:100 rcspline.eval(x, nk=4, inclx=TRUE) #lrm.fit(rcspline.eval(age,nk=4,inclx=TRUE), death)