Description Usage Arguments Value
This function was created to avoid repeating it over and over in my research. The penalty for each marginal term is \int \|f''(x)\|^2 dx.
1 | get_basis_expansion(df, num.knots, bases, interactions, knots.list = NULL)
|
df |
data frame for which to expand. Must already contain an intercept in column 1, and all covariates should be scaled between 0 and 1. |
num.knots |
a vector containing the number of knots to use for each predictor. |
bases |
a vector containing the bases to use for each expansion. Cubic ( |
interactions |
logical: should two-way interactions (tensor products) be computed? |
knots.list |
optional list containing knots to use. Useful for predictions. If present, num.knots is ignored. |
A list with components:
C.full
a matrix containing all basis expansions, with the intercept.
partition
a numeric vector corresponding to group identification. 0
corresponds to the intercept.
nvar, pc, pz, px
scalars giving the number of total predictors (including 2-way interactions as individual predictors, if interactions == TRUE
),
total dimension of C.full
, and the dimensions of the linear and basis expansion terms, respectively.
knots.list
a list of knots used for expansion. Useful for creating the same basis expansion on an independent data set (for, say, validation).
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.