dkesada / dbnR

Gaussian dynamic Bayesian networks structure learning and inference based on the bnlearn package
GNU General Public License v3.0
44 stars 10 forks source link

Forecasting plot does not show predictions #12

Closed dkesada closed 2 years ago

dkesada commented 2 years ago

When performing forecasting with the forecast_ts() function, if the predictions are outside the range of the original values they will not be seen in the plot. This is due to the order of the plot + line calls: the plot function is called first on the original time series, and afterwards the predictions are added on top of that plot with the lines function. It is common to find this scenario when the original time series does not have large variations, and so the forecasting can be outside this range. This behaviour can be misleading, because the forecasting is made, but in the plot it looks like the model didn't do anything.

To fix this, instead of plotting the original time series without taking into account the predictions, the frame should be built based on the range of values of both the prediction and the forecasting.

A couple of plots illustrating the issue:

dkesada commented 2 years ago

Fixed now in devel branch, on commit e7ed3edffb6c6b1b9c30d0e65e7a0d49fbe6c3fc