Define Knots at Equally-Spaced Values
This function defines the position of knot or cut-off values at equally-spaced values for spline or strata functions, respectively.
equalknots(x, nk=NULL, fun="ns", df=1, degree=3, intercept=FALSE)
x |
a vector variable. |
nk |
number of knots or cut-offs. |
fun |
character scalar with the name of the function for which the knots or cut-offs must be created. See Details below. |
df |
degree of freedom. |
degree |
degree of the piecewise polynomial. Only for |
intercept |
logical. If an intercept is included in the basis function. |
The number of knots is set with the argument nk
, or otherwise determined by the choice of function and number of degrees of freedom through the arguments fun
and df
. Specifically, the number of knots is set to df-1-intercept
for "ns"
, df-degree-intercept
for "bs"
, or df-intercept
for "strata"
.
A numeric vector of knot or cut-off values.
Antonio Gasparrini <antonio.gasparrini@lshtm.ac.uk>
logknots
for placing the knots at equally-spaced log values. crossbasis
to generate cross-basis matrices.
See dlnm-package
for an introduction to the package and for links to package vignettes providing more detailed information.
### setting 3 knots for range 0-20 equalknots(20, 3) ### setting knots and cut-offs for different functions equalknots(20, fun="ns", df=4) equalknots(20, fun="bs", df=4, degree=2) equalknots(20, fun="strata", df=4) ### with and without without intercept equalknots(20, fun="ns", df=4) equalknots(20, fun="ns", df=4, intercept=TRUE)
Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.