Description Usage Arguments Details Value Author(s) See Also Examples
This function defines the position of knot or cut-off values at equally-spaced log-values for spline or strata functions, respectively. It is expressely created for lag-response functions to set the knots or cut-offs placements accordingly with the default of versions of dlnm earlier than 2.0.0.
1 |
x |
an integer scalar or vector of length 2, defining the the maximum lag or the lag range, respectively, or 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. |
This functions has been included for consistency with versions of dlnm earlier than 2.0.0, where the default knots or cut-off placements in the lag space for functions ns
, bs
and strata
used to be at equally-spaced values in the log scale. Since version 2.0.0 on, the default is equally-spaced quantiles, similarly to functions defined for the space of predictor. This function can be used to replicate the results obtained with old versions.
The argument x
is usually assumed to represent the maximum lag (if a scalar) or the lag range (if a vector of length 2). Otherwise is interpreted as a vector variable for which the range is computed internally.
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"
.
An intercept is included by default (intercept=TRUE
), consistently with the default for the lag space.
A numeric vector of knot or cut-off values, to be used in the arglag
list argument of crossbasis
for reproducing the default of versions of dlnm earlier than 2.0.0.
Antonio Gasparrini <antonio.gasparrini@lshtm.ac.uk>
equalknots
for placing the knots at equally-spaced 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.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | ### setting 3 knots for lag 0-20
logknots(20, 3)
logknots(c(0,20), 3)
### setting knots and cut-offs for different functions
logknots(20, fun="ns", df=4)
logknots(20, fun="bs", df=4, degree=2)
logknots(20, fun="strata", df=4)
### with and without without intercept
logknots(20, fun="ns", df=4)
logknots(20, fun="ns", df=4, intercept=FALSE)
### replicating an old example in time series analysis
lagknots <- logknots(30, 3)
cb <- crossbasis(chicagoNMMAPS$temp, lag=30, argvar=list(fun="bs",df=5,
degree=2), arglag=list(knots=lagknots))
summary(cb)
library(splines)
model <- glm(death ~ cb + ns(time, 7*14) + dow,
family=quasipoisson(), chicagoNMMAPS)
pred <- crosspred(cb, model, cen=21, by=1)
plot(pred, xlab="Temperature", col="red", zlab="RR", shade=0.6,
main="3D graph of temperature effect")
|
This is dlnm 2.3.9. For details: help(dlnm) and vignette('dlnmOverview').
[1] 0.9989336 2.7124876 7.3654431
[1] 0.9989336 2.7124876 7.3654431
[1] 1.393628 5.279448
[1] 2.712488
[1] 0.9989336 2.7124876 7.3654431
[1] 1.393628 5.279448
[1] 0.9989336 2.7124876 7.3654431
CROSSBASIS FUNCTIONS
observations: 5114
range: -26.66667 to 33.33333
lag period: 0 30
total df: 25
BASIS FOR VAR:
fun: bs
knots: 1.666667 10.55556 19.44444
degree: 2
intercept: FALSE
Boundary.knots: -26.66667 33.33333
BASIS FOR LAG:
fun: ns
knots: 1.105502 3.322105 9.983144
intercept: TRUE
Boundary.knots: 0 30
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.