Reputation: 495
I am trying to predict using holt().
holt(ts(c(999037.5, 998362.5, 999525.0, 999412.5, 1000000.0)),alpha=0.6, beta=0.6, damped=TRUE, initial="optimal", h=5)
I get the following error:
Error in ets(x, "AAN", alpha = alpha, beta = beta, damped = damped, opt.crit = "mse", :
Sorry, but I need more data!
But when I run the following code, I get the output.
holt(ts(c(1,2)),alpha=0.6, beta=0.6, damped=TRUE, initial="optimal", h=5)
Point Forecast Lo 80 Hi 80 Lo 95 Hi 95
3 1.5 0.5938062 2.406194 0.11409618 2.885904
4 1.5 0.4868445 2.513155 -0.04948758 3.049488
5 1.5 0.3901438 2.609856 -0.19737860 3.197379
6 1.5 0.3012183 2.698782 -0.33337843 3.333378
7 1.5 0.2184484 2.781552 -0.45996398 3.459964
So I am not sure what the issue is.
Upvotes: 2
Views: 181
Reputation: 7895
Inside the code of ets
you find:
# close to line 148
n <- length(y)
if (n <= 4) {
fit <- HoltWintersZZ(orig.y, beta = FALSE, gamma = FALSE,
lambda = lambda, biasadj = biasadj)
fit$call <- match.call()
return(fit)
}
npars <- 2L
if (trendtype == "A" | trendtype == "M")
npars <- npars + 2L
if (seasontype == "A" | seasontype == "M")
npars <- npars + m
if (!is.null(damped))
npars <- npars + as.numeric(damped)
if (n <= npars + 1)
stop("Sorry, but I need more data!")
if (errortype == "Z")
errortype <- c("A", "M")
if (trendtype == "Z") {
if (allow.multiplicative.trend)
trendtype <- c("N", "A", "M")
else trendtype <- c("N", "A")
}
So one of these if
statements is being triggered.
Upvotes: 2