accuracy() and error-in-xx-ff1n-non-numeric-argument-to-binary-opera

I'm new to time series. While building a basic predictive model I ran into "> Error in xx - ff[1:n] : non-numeric argument to binary operator".

library(forecast)

dj60 <- window(dowjones, end = 60)

dj60.rwf.drift <- rwf(dj60, h = 18, drift = TRUE)

dj60.od <- window(dowjones, start = 61)

accuracy(dj60.od, dj60.rwf.drift)

Returns:

Error in xx - ff[1:n] : non-numeric argument to binary operator

The preceding chain of commands works for another data set:

library(forecast)
library(fpp2)

vn_Melbourne_train1 <- window(visnights[, "QLDMetro"], end = c(2014, 4))

snaive_vn_Melbourne_train1 <- snaive(vn_Melbourne_train1, h = 4)

vn_Melbourne_test1 <- window(visnights[, "QLDMetro"], start = c(2015, 1), end = c(2015, 4))

accuracy(snaive_vn_Melbourne_train1, vn_Melbourne_test1)

I have str() ed all of the objects and find them comparable.

Why does this error occur for one data set and not the other?

The accuracy function has inputs accuracy(forecast, new_data). So your code should be: accuracy(dj60.rwf.drift, dj60.od)

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.