好吧,所以我们从预测包文档中知道hw()
基本上是forecast(ets(...))
的包装函数。但是,我想确切地知道哪种ETS公式等同于拟合+预测“加性” Holt-Winters(如hw(x, seasonal="additive")
和“乘性” Holt-Winters(如hw(x, seasonal="multiplicative")
)。< / p>
(i)我猜想可以使用带有=“ AAA”模型的ets函数来实现“加和”的Holt-Winters公式(结果大致相同,通常小数点或第一个单位的差异很小)。正确吗?
(ii)乘积Holt-Winters-hw(x, seasonal="multiplicative")
的ETS等效项是什么?
谢谢!
答案 0 :(得分:1)
R是开源的。只看代码。这并不困难。这是hw()
函数的第一部分。
> hw
function(y, h = 2 * frequency(x), seasonal = c("additive", "multiplicative"), damped = FALSE,
level = c(80, 95), fan = FALSE, initial=c("optimal", "simple"), exponential=FALSE,
alpha=NULL, beta=NULL, gamma=NULL, phi=NULL, lambda=NULL, biasadj=FALSE, x=y, ...) {
initial <- match.arg(initial)
seasonal <- match.arg(seasonal)
m <- frequency(x)
if (m <= 1L) {
stop("The time series should have frequency greater than 1.")
}
if (length(y) < m + 3) {
stop(paste("I need at least", m + 3, "observations to estimate seasonality."))
}
if (initial == "optimal" || damped) {
if (seasonal == "additive" && exponential) {
stop("Forbidden model combination")
} else if (seasonal == "additive" && !exponential) {
fcast <- forecast(ets(x, "AAA", alpha = alpha, beta = beta, gamma = gamma, phi = phi, damped = damped, opt.crit = "mse", lambda = lambda, biasadj = biasadj), h, level = level, fan = fan, ...)
} else if (seasonal != "additive" && exponential) {
fcast <- forecast(ets(x, "MMM", alpha = alpha, beta = beta, gamma = gamma, phi = phi, damped = damped, opt.crit = "mse", lambda = lambda, biasadj = biasadj), h, level = level, fan = fan, ...)
} else { # if(seasonal!="additive" & !exponential)
fcast <- forecast(ets(x, "MAM", alpha = alpha, beta = beta, gamma = gamma, phi = phi, damped = damped, opt.crit = "mse", lambda = lambda, biasadj = biasadj), h, level = level, fan = fan, ...)
}
}
您不必读很远就可以知道,如果seasonal='multiplicative'
和exponential=FALSE
(默认值)是模型,则该模型为MAM。