tslars {tslars} | R Documentation |
The tslars
function applies a dynamic variable selection procedure. It is an extension of the LARS
algorithm of Efron et al (2004) which is designed for time series analysis. It provides a ranking of the
predictors and a selection of which predictors to include in the final model as well as a selection of the
appropriate lag length.
tslars(formula, h = 1, p.max = 5, max.x = 10, nr.rank = NA)
formula |
a formula describing the model to be fitted |
h |
the forecast horizon, defaults to 1. |
p.max |
the maximal number of lags to allow, defaults to 5. |
max.x |
the maximal number of predictors to include in the final model, defaults to 10. |
nr.rank |
the number of predictors to be ranked. This is especially interesting if the total number of predictors is really large. |
A tslars
-object is returned, for which print()
, summary()
, predict()
and coef()
are available.
An object of class "lm" is a list containing the following components:
active |
the active set, a vector giving the TS-LARS ordering of the predictors, '0' indicates lagged values of the response. |
fixedp |
indicates whether the lag length was prespecified (TRUE ) or not (FALSE ). |
laglength.opt |
if fixedp is TRUE , the prespecified lag length. If fixedp is FALSE , the optimal lag length selected according to BIC. |
nrvar.opt |
the optimal number of predictors to include in the final model, according to the BIC. |
bic |
the BIC values for the nested models. |
h |
the forecast horizon used. |
call |
the matched call. |
response |
the response used. |
predictors |
the predictors used. |
Sarah Gelper
Gelper, S. and Croux, C. (2009) Time series least angle regression for selecting predictive economic sentiment series. www.econ.kuleuven.be/sarah.gelper/public
n <- 100 m <- 10 #m>5 x <- matrix(rnorm(n*m), ncol=m) coefs <- c(rep(1,5),rep(0,m-5)) y <- c(rnorm(1),crossprod(t(x[1:(n-1),]),coefs) + rnorm(n-1)) mytslars <- tslars(y~x) summary(mytslars) # To obtain an h-step-ahead prediction of the response using the selected model fitted by OLS: myprediction <- predict(mytslars)