1
$\begingroup$

I have a problem similar to the one presented in this post : https://stackoverflow.com/questions/11092536/forecast-accuracy-no-mase-with-two-vectors-as-arguments even if it's maybe not related. I'm trying to make predictions of hierarchical time series using hts package but i have an error when i tried to compute the MASE between models.

The vignette example is on yearly data :

data <- window(htseg1, start = 1992, end = 1999)
test <- window(htseg1, start = 2000, end = 2001)
forecast <- forecast(data, h = 2, method = "bu")
accuracy.gts(f = forecast, x = test)

but when i try to use the function on monthly data this part of code seems to pose problem:

allx <- allts(x)
allf <- allts(f)

if (is.element("MASE", criterion)) {
        m <- frequency(f$y)
        if (m <= 1) 
            scale <- colMeans(diff(allx))
        else scale <- colMeans(diff(allx, lag = m))
        q <- sweep(res, 2, scale, "/")
}

as I want to compute the MASE on 4 period and the frequency of my data is 12 the colMeans(diff(allx, lag = m)) fails (no problem in the vignette example because m=1).

What surpise me is that in the post I quoted, Rob Hyndman said : "The MASE requires the historical data to compute the scaling factor. It is not computed from the future data" so the scale should be compute with allf which contains the forecast/historical data. Or x is supposed to contains all the historical data and it's not consistent with the vignette example.

Do I miss something ?

$\endgroup$
1
$\begingroup$

I suspect that your historical data is less than m periods long, so the differencing at lag m is returning nothing. I will add a trap in the code to return a meaningful error message.

If this isn't the problem, then please provide a replicable example.

$\endgroup$

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.