Learn R Programming

dlnm (version 0.3.0)

dlnm-internal: Internal functions for package dlnm

Description

Generate the basis functions for the space of predictor and lags. These functions are built for internal use only.

Usage

mkbasis(var, type="ns", df=1, knots=NULL, bound = range(var),
	int=FALSE, cen=TRUE, cenvalue=mean(var))

mklagbasis(maxlag=0, type="ns", df=1, knots=NULL,
	bound=c(0, maxlag), int=TRUE)

Arguments

var
a numeric vector of ordered observations.
type
type of basis.
df
dimension of the basis. They depend on varknots and lagknots if provided.
knots
knots location for the basis.
bound
boundary knots. Used only if type="ns".
int
logical. If TRUE, an intercept is included in the basis.
cen
logical. If TRUE, the basis functions are centered.
cenvalue
centering value.
maxlag
maximum lag.

Value

  • basismatrix of basis functions
  • Additional values are returned that correspond to the arguments above, and explicitly give type, df, knots, bound, int, varcen, cenvalue and maxlag related to the corresponding basis.

Details

These functions are called by crossbasis in order to build the related cross-basis functions. See crossbasis for further details.

References

Armstrong, B. Models for the relationship between ambient temperature and daily mortality. Epidemiology. 2006, 17(6):624-31.

Examples

Run this code
mkbasis(1:5, knots=3)
mkbasis(1:5, type="thr", knots=3)
mklagbasis(maxlag=5, type="poly", df=3)

# the intercept
mklagbasis(maxlag=10, type="strata", knots=c(4,7))
mklagbasis(maxlag=10, type="strata", knots=c(4,7), int=FALSE)

# centering
mkbasis(0:10, type="poly", df=3)
mkbasis(0:10, type="poly", df=3, cen=FALSE)

### See the vignette 'dlnmOverview' for a detailed explanation of this example

Run the code above in your browser using DataLab