L {bayesGAM} | R Documentation |
Lag function for autoregressive models
Description
Creates lagged variables for use with bayesGAM
, including the functionality
to create lags for each specified subject if desired. The input data must be pre-
sorted according by time, and within each subject id if specified.
Usage
L(x, k = 1, id = NULL)
Arguments
x |
numeric vector |
k |
integer vector of lagged variables to create |
id |
optional identification number for each subject |
Value
numeric vector or matrix of the lagged variable(s)
References
Zeileis A (2019). dynlm: Dynamic Linear Regression. R package version 0.3-6
Examples
x <- rnorm(20)
id <- rep(1:4, each=5)
L(x, 1:2, id)
# autoregressive
ar.ols(lh, demean = FALSE, intercept=TRUE, order=1)
f <- bayesGAM(lh ~ L(lh), family=gaussian)
coef(f)
[Package bayesGAM version 0.0.2 Index]