dlim {dlim}R Documentation

Fit DLIM

Description

Fit distributed lag interaction model

Usage

dlim(
  y,
  x,
  modifiers,
  z = NULL,
  df_m,
  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 (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 the bam function for data sets that are very large. Default will fit using gam. (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

See Also

Type vignette('dlimOverview') for a detailed description.

predict.dlim

plot_cumulative

plot_DLF

Examples

library(dlim)
data("ex_data")
dlim_fit <- dlim(y = ex_data$y, 
                 x = ex_data$exposure, 
                 modifier = ex_data$modifier, 
                 z = ex_data$z, 
                 df_m = 10, 
                 df_l = 10, 
                 method = "REML")
dlim_pred <- predict(dlim_fit, 
                     newdata = 0.5, 
                     type="CE")

[Package dlim version 0.1.0 Index]