Add Lagged Responses as Predictors to Each Channel of a dynamite Model
Add Lagged Responses as Predictors to Each Channel of a dynamite Model
Adds the lagged value of the response of each channel specified via dynamiteformula() as a predictor to each channel. The added predictors can be either time-varying or time-invariant.
lags(k =1L, type = c("fixed","varying","random"))
Arguments
k: [integer()]
Values lagged by k units of time of each observed response variable will be added as a predictor for each channel. Should be a positive (unrestricted) integer.
type: [integer(1)]
Either "fixed" or "varying" which indicates whether the coefficients of the added lag terms should vary in time or not.
Returns
An object of class lags.
Examples
data.table::setDTthreads(1)# For CRANobs(y ~-1+ varying(~x), family ="gaussian")+ lags(type ="varying")+ splines(df =20)# A two-channel categorical model with time-invariant predictors# here, lag terms are specified manuallyobs(x ~ z + lag(x)+ lag(y), family ="categorical")+ obs(y ~ z + lag(x)+ lag(y), family ="categorical")# The same categorical model as above, but with the lag terms# added using 'lags'obs(x ~ z, family ="categorical")+ obs(y ~ z, family ="categorical")+ lags(type ="fixed")
See Also
Model formula construction dynamite(), dynamiteformula(), lfactor(), random_spec(), splines()