View source: R/dataframe_DLM.R
dataframe_DLM | R Documentation |
Transforms a dataframe to prepare it for distributed lag modelling.
dataframe_DLM(X, lag, dynamic_vars = NULL, arglag = list(fun = "bs"), ...)
X |
A dataframe, or something that can be coerced into one. |
lag |
Lag length of the dynamic variable. See |
dynamic_vars |
The column name or indices that correspond to the longitudinal variables. If left missing, the dataset is not altered in any way and a warning is supplied. |
arglag |
A list that is passed into |
... |
Further arguments to be passed into the |
The purpose of this function is to streamline the preperation of the data for distributed lag modelling in the case where every dynamic variable is handled the same way.
If no dynamic variables are given, the input dataframe is returned unaltered with a warning. Otherwise, the function returns a dataframe_DLM object, which is essentially treated like a standard dataframe but contains extra information to simplify the process of distributed lag modelling when using the NB_MCMC or QB_MCMC functions.
The input is returned unchanged if no dynamic variables are given. Otherwise a dataframe_DLM object is returned. See details.
Daniel Dempsey (daniel.dempsey0@gmail.com)
X <- dplyr::select( dlnm::chicagoNMMAPS, c('cvd', 'dow', 'temp', 'dptp', 'o3') )
X <- na.omit( X )
arglag <- list( fun = 'bs', df = 4 )
DLM_dat <- dataframe_DLM( X, lag = 40, dynamic_vars = c('temp', 'dptp', 'o3'), arglag = arglag )
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.