tvp.ridge: Time-Varying Parameters via Ridge Regressions

Description Usage Arguments Value Author(s) References Examples

View source: R/MV2SRR_v210407.R

Description

This prototype function runs the 2-step Ridge Regression technique in Goulet Coulombe (2020). Basically, the technique allowing parameters of a linear equation(s) to evolve as driftless random walks and computations are carried via a closed-form solution in the form of data-augmented ridge regression rather than with typically burdensome filtering procedures. It handles the univariate and multivariate cases, and performs cross-validation of lambda (the amount of time variation). It will especially fast when T is below 1000, which is customary for macroeconomic time series, on which TVP models are often applied.

Usage

1
2
3
tvp.ridge(X,Y,lambda.candidates=exp(linspace(-6,20,n=15)),oosX=c(),
                      lambda2=.1,kfold=5,CV.plot=TRUE,CV.2SRR=TRUE,
                      sig.u.param=.75,sig.eps.param=.75,ols.prior=0)

Arguments

X

Predictors (T * K)

Y

Targets (T * M), where M can be 1 (univariate case)

lambda.candidates

Candidate values for lambda (amount of time variation) to evaluate by CV.

oosX

A vector of X for which to produce one out-of-sample forecast. Since parameters evolve according to random walks, one should need to reevaluate at each t.

lambda2

Penalty on beta_0 (starting values of the random walks). Keep it soft unless X is large.

kfold

Number of folds for CV (5 or 10, usually).

CV.plot

If Switched to TRUE, the function will plot CV graph, which can be a useful check of whether your lambda.candidates are legit.

CV.2SRR

Should we cross-validate again after the weight updating step? Can help marginally at low cost for small models. Can help marginally but incurs a higher computational cost for large X or Y.

sig.u.param

How much should we shrink sigma_u estimates to the homogenous case? 1 is not at all, and 0 is completely. Intermediate values like 0.25, 0.5, and 0.75 are recommended. The formula is final.sig.u = [(hetero)^(sig.u.param)]*[(homo)^(1-sig.u.param)].

sig.u.param

How much should we shrink sigma_eps estimates to the no-evolving volatility case? 1 is not at all, and 0 is completely. Intermediate values like 0.25, 0.5, and 0.75 are recommended. The formula is final.sig.eps = [(Garch(1,1))^(sig.u.param)]*[(homo)^(1-sig.u.param)].

ols.prior

Will shrink beta_0 (at a strength given by lambda2) to OLS rather than 0. Not recommended unless X is very small. The Half & Half strategy described in the paper is typically preferable.

Value

betas.rr

Betas from a plain ridge regression (no two steps).

betas.2srr

Betas from 2SRR (M * K * T).

lambdas

Choice of lambda by CV. Will be a vector if M>1.

forecast

A forecast for y if oosX was supplied. Will be a vector if M>1.

sig.eps

Normalized evolving volatility weights.

yhat.rr

In-sample span from a one-step approach. Will be a matrix if M>1.

yhat.2srr

In-sample span from 2srr. Will be a matrix if M>1.

Author(s)

Philippe Goulet Coulombe

References

Original paper is https://arxiv.org/abs/2009.00401

Examples

1
2
3
4
5
6
7
#data
data=matrix(rnorm(15*200),200,15)
X=data[,1:3]
Y=crossprod(t(X),rep(1,3))*(1-0.5*I(c(1:200)>75))+rnorm(200)/2

#2SRR
results <- tvp.ridge(Y=Y,X=X)

philgoucou/tvpridge documentation built on Dec. 22, 2021, 7:49 a.m.