Internal function extracting design matrices from formulas in the DALSM function and computing penalty related matrices
Internal function extracting design matrices from formulas in the DALSM function and computing penalty related matrices
Internal function extracting design matrices from formulas in the DALSM function and computing penalty related matrices.
DesignFormula(formula, data, K =10, pen.order =2, n =NULL)
Arguments
formula: a formula describing the fixed effects and the additive terms in a regression model.
data: a dataframe containing the data.
K: number of B-splines to describe an additive term.
pen.order: desired penalty order for the spline parameters in the additive terms.
n: number of units (Default: number of rows in the design matrix constructed from the formula and the data frame).
Returns
a list with
Z : (n x nfixed) design matrix with fixed effects (including a first column of 1).
X : (n x J) design matrix with the covariates involved in the additive terms.
nfixed : number of fixed effect regression parameters.
J : number of additive terms.
K : number of B-splines in a basis used to estimate an additive term.
Bx : list with J objects (one per additive term) including (B,Dd,Pd,K,cm).
Pd.x, Dd.x : penalty and difference penalty matrices applied on the spline parameters of an additive term.
knots.x : list of length J with the knots associated to each of the J additive terms.
Bcal : column-stacked matrix with the J centered B-spline bases.
Xcal : Z column-stacked with the J centered B-spline bases to yield the full design matrix (with column labels).
pen.order : penalty order for the spline parameters in the additive terms.
additive.lab : labels for the columns in <Bcal> associated to the additive terms.
lambda.lab : labels for the penalty parameters.
References
Lambert, P. (2021). Fast Bayesian inference using Laplace approximations in nonparametric double additive location-scale models with right- and interval-censored data. Computational Statistics and Data Analysis, 161: 107250. doi:10.1016/j.csda.2021.107250