# basis: Basis vectors In asw221/dlm: Distributed Lag Models for Built Environment Applications

## Description

Constructs a set of basis vectors C_0 and K_1 used to constrain distributed lag coefficients, β, using splines. The basis vectors depend on the radii that define ring-shaped areas around participant locations. Typical usage relies on calling basis application functions, like cr (e.g. in dlm model formulas); users should not often have to interact with basis directly.

## Usage

 1 basis(x, center = TRUE, scale = FALSE, .fun = NULL, ...) 

## Arguments

 x radii that define ring-shaped areas around participant locations center if TRUE (the default), x will be mean centered prior to computing the basis. Otherwise, if given a numeric value, x will be centered at center scale if TRUE (default = FALSE), parameter x will be scaled by sd(x). Otherwise, if given a numeric value, x will be scaled by scale .fun a function to define the type of basis. The default is to compute a cubic radial basis based on pairwise cubed absolute differences among the radii. See Details ... other parameters passed to .fun

## Details

Alternative distance functions, .fun, may be specified, and error checking on the user's choice of .fun is deliberately missing. Proper candidates for .fun should return an (L \times L) matrix, where L is the same as length(x); elements of this matrix are typically non-negative.

function(x, y, ...)

 if (missing(y)) y <- x

 ...

The default value of .fun computes cubic radial distance, which amounts to abs(outer(x, y, "-"))^3; the computed vectors are then transformed following Rupert, Wand, and Carroll (2003), such that the spline can be fitted (and penalized) as a mixed-model.

## Value

An object of class LagBasis

## Decomposition

Once a basis function (δ()) and radii (r) are chosen, define the matrix, C_1[i, j] = δ(r_i, r_j), and let,

C_0 = [1, r]

C_1 = Q * R

M_1 = Q[-(1:2)]

K_1 = C_1 * M_1 * (M_1' * C_1 * M_1)^-0.5

where A[-j] denotes a matrix A with column(s) j removed. Then the (scaled) distributed lag effects are β = C_0 * α + K_1 * b, where b_l ~ N(0, σ^2_b), for l = 1, ..., L - 2.

## References

Rupert D, Wand MP, & Carroll RJ (2003) Semiparametric Regression. New York: Cambridge University Press.

cr, dlm