NorskRegnesentral/shapr

Possible bug in explain_forecast without lag explanation

martinju opened this issue · 0 comments

There seems to be a bug in the test "forecast_output_arima_numeric_no_lags":

test_that("forecast_output_arima_numeric_no_lags", {
# TODO: Need to check out this output. It gives lots of warnings, which indicates something might be wrong.
expect_snapshot_rds(
explain_forecast(
model = model_arima_temp,
y = data[1:150, "Temp"],
xreg = data[, "Wind"],
train_idx = 2:148,
explain_idx = 149:150,
explain_y_lags = 0,
explain_xreg_lags = 0,
horizon = 3,
approach = "independence",
prediction_zero = p0_ar,
group_lags = FALSE,
n_batches = 1,
timing = FALSE
),
"forecast_output_arima_numeric_no_lags"
)
})

A warning is thrown whenever predict_model is called. The warning is
Warning in matrix(): data length [2] is not a sub-multiple or multiple of the number of rows [3]
and comes from the following line:

xreg_pred <- matrix(newreg[i, ], horizon)

Althoug this is just a warning, I suspect it causes erroronous behavior.

@jonlachmann: Since you know this code the best, do you mind taking a look?