Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Out-of-sample evaluation #42

Open
sehoff opened this issue Oct 25, 2022 · 2 comments
Open

Out-of-sample evaluation #42

sehoff opened this issue Oct 25, 2022 · 2 comments

Comments

@sehoff
Copy link

sehoff commented Oct 25, 2022

I am sorry to ask this probably naive question, but I need to be sure and I am not coding in R often.

  • When using cv.BigVAR() the right-hand side endogenous variables are automatically lagged?
  • results@preds in the example below are oos predictions, i.e., the first prediction is obtained from an estimation up to T_2 for T_2 +1. The next predictions are rolled over by one period, in my case, keeping the optimal lambda fixed?
  • I need to lag exogenous variables myself, such that the timing corresponds to equation (1) in the vignette.

Here is my code, which should give for each of the endogenous variables in the system a separate OOS R2 (benchmarked wrt to conditional mean forecast):

VARX=list(k=5,s=1)
mod1<-constructModel(y_full,
                    VARX=VARX,
                    p=1,
                    "BasicEN",
                    gran=c(100,10),
                    h=1,
                    cv="Rolling",
                    verbose=FALSE,
                    IC=TRUE,
                    model.controls=list(intercept=TRUE, alpha=0.5))

results=cv.BigVAR(mod1)

model.pred <- results@preds
mean.pred  <- results@MeanPreds
# test dep var
y.test     <- y[floor(2/3*nrow(y_full)+1):nrow(y_full),]
# MSFE
msfe.model <- colMeans((y.test - model.pred)**2)
msfe.mean  <- colMeans((y.test - mean.pred)**2)
# OOS R2
1- msfe.model/msfe.mean
@wbnicholson
Copy link
Owner

When using cv.BigVAR() the right-hand side endogenous variables are automatically lagged?

Yes, the both endogenous and exogenous variables are lagged automatically according to p and s in constructModel.

results@preds in the example below are oos predictions, i.e., the first prediction is obtained from an estimation up to T_2 for T_2 +1. The next predictions are rolled over by one period, in my case, keeping the optimal lambda fixed?

Yes, that's correct.

I need to lag exogenous variables myself, such that the timing corresponds to equation (1) in the vignette.

This is done automatically by BigVAR. If you have a non-standard lag order, you can lag it yourself and set s=0 and tf=TRUE which will not perform and lagging.

Your code looks correct. Let me know if you have additional questions.

@sehoff
Copy link
Author

sehoff commented Oct 26, 2022

Thanks a lot for the quick reply!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants