gpt4 book ai didi

R 预测包 - 加法和乘法 hw() - 在 ETS 函数中等效

转载 作者:行者123 更新时间:2023-12-05 06:33:02 28 4
gpt4 key购买 nike

好的,所以我们从预测包文档中知道 hw() 基本上是 forecast(ets(...)) 的包装函数。但是,我想确切地知道哪种 ETS 公式相当于拟合 + 预测“加法”Holt-Winters(如 hw(x, seasonal="additive") 和“乘法”Holt - 冬季(如 hw(x, seasonal="multiplicative")

(i) 我猜想可以使用带有 model="AAA"的 ets 函数来实现“加法”Holt-Winters 公式(结果大致相同,通常小数点或第一个单位的差异很小)。对吗?

(ii) 乘法 Holt-Winters 的 ETS 等价物如何 - hw(x, seasonal="multiplicative")

提前致谢!

最佳答案

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。

关于R 预测包 - 加法和乘法 hw() - 在 ETS 函数中等效,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50937354/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com