0
$\begingroup$

I am sure, I am doing some thing extremely silly but for the life of me not able to figure our cause of the issue.

So here it is:

Step 0: Form my training set

Y = pd.concat([LTM_Q_stat_train, BLS_Q_stat_train],axis=1)

Step 1 : Standard VAR model forecasting of OOS data (Y is my training set)

LTM_Q_pred = LTM_Q_var.forecast(Y.values[-5:],10)
LTM_Q_pred = pd.DataFrame(LTM_Q_pred, index = Y.index[-10:], columns = Y.columns)

Printing the LTM_Q_pred gives us these values:

Date        Rate        Standards
2016-10-31  -0.000567   0.108688
2017-01-31  0.000341    -0.610666
2017-04-30  0.000888    5.526692
2017-07-31  0.003053    -0.519169
2017-10-31  0.003449    -1.824571
2018-01-31  0.002106    0.321552
2018-04-30  0.000827    -0.599766
2018-07-31  -0.000434   -1.329977
2018-10-31  -0.001420   -1.101982
2019-01-31  -0.001552   -1.513516

With me so far?

Step 2: Let's plot it against the data:

fig,ax = plt.subplots(figsize=(12,5))
LTM_Q_stat[1:90].plot(ax=ax)
LTM_Q_pred['Rate'].plot(ax=ax)
LTM_Q_var.plot_forecast(10);

As a result, I get this:

enter image description here enter image description here

For the moment I am only interested in 'Rate', so let's focus on that. Clearly my indexing is off. So let's try to look at the tail of my training dataframe as well.

Y.tail(5)

Date        Rate    Standards
2018-01-31  0.004285    -1.5
2018-04-30  0.001142    -1.3
2018-07-31  -0.002549   -4.6
2018-10-31  0.000926    0.0
2019-01-31  -0.003454   18.7

and LTM_Q_stat[70:80] gives me this:

Date         Rate
2016-10-31  -0.000938
2017-01-31  -0.005851
2017-04-30  -0.003983
2017-07-31  -0.000794
2017-10-31  0.001179
2018-01-31  0.004285
2018-04-30  0.001142
2018-07-31  -0.002549
2018-10-31  0.000926
2019-01-31  -0.003454

Clearly I have gone wrong with indexing somewhere. However I am not able to figure out how can I get my overlay plot to look similar to the plot_forecast plot that is shown by the internal function of VAR module.

Help deeply appreciated

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.