Fit distributed lag interaction model
Usage
dlim(
y,
x,
modifiers,
z = NULL,
df_m = NULL,
df_l,
penalize = TRUE,
pen_fn = "ps",
mod_args = NULL,
lag_args = NULL,
fit_fn = "gam",
model_type = "standard",
ID = NULL,
...
)
Arguments
- y
vector of response values (class "
numeric
")- x
matrix of exposure history (columns) for individuals (rows) (class "
matrix
")- modifiers
vector of modifying values (class "
numeric
")- z
matrix of covariates, not including the modifier (class "
matrix
")- df_m
degrees of freedom for modifier basis. Cannot specify for linear modification (model_type = "linear") (class "
numeric
")- df_l
degrees of freedom for exposure time basis (class "
numeric
")- penalize
TRUE
to penalize model (class "logical
")- pen_fn
if penalizing, can specify "ps" for penalized B-splines or "cr" for cubic regression splines with penalties on second derivatives
- mod_args
a list of additional arguments for the spline function (must be named by argument)
- lag_args
a list of additional arguments for the spline function (must be named by argument)
- fit_fn
specify "gam" to use the
gam
function for data sets that are not very large, and specify "bam" to use thebam
function for data sets that are very large. Default will fit usinggam
. (class "character
")- model_type
"linear" for a DLIM with linear interaction, "quadratic" for a DLIM with quadratic interaction, "standard" for a DLIM with splines (class "
character
")- ID
group identifier for random intercept, only supported for penalized models
- ...
Other arguments to pass to model fitting function
Value
This function returns a list that is an object of class "dlim
" with the following components
- cb
cross-basis (class "
matrix
")- fit
model object (class "
lm
", "glm
", "gam
")- modifiers
modifying values (class "
numeric
")- call
model call