mapa Multiple Aggregation Prediction Algorithm (Wrapper)
我想使用 MAPA 包中的 mapa 函数,一切正常,我的意思是一切,如果我将类型留空,它确实会产生预测。
但使用:
type = 'es'
产生错误,我不知道为什么,因为文档说:
<<type 使用什么类型的指数平滑实现。 “es” = 从光滑包中使用; “ets” = 从预测包中使用。默认为“es”>>
https://cran.r-project.org/web/packages/MAPA/MAPA.pdf
使用 type = 'ets' 效果很好,或者只是不添加该参数。我想使用 xreg,但不能,因为它强制 type = 'es',从而产生错误。
> mapa(ts(c(1:80), frequency = 1), type = 'ets', outplot = 1)
MAPA fit MSE: 0.02, MAE: 0.13
Out-of-samplpe forecasts:
[1] 81.125
这是错误
> mapa(ts(c(1:80), frequency = 1), type = 'es', outplot = 1)
Error in !silent : invalid argument type
我已经重新安装了 MAPA 和 smooth 软件包。
devtools::install_github("config-i1/smooth")
devtools::install_github("trnnick/mapa")
这似乎是一个错误。
mapa::mapa
来电
# Turn off warnings for es - this is done when the model reduces pool
# due to sample size.
fittemp <- suppressWarnings(es(ats,model=mapa.model,silent="all",xreg=xregA, ...))
(https://github.com/trnnick/mapa/blob/master/R/mapa.estim.R#L304)
到目前为止还好,但是如果我们看一下
smooth/R/es.R
,我们会看到函数声明是
es_old <- function(y, model="ZZZ", persistence=NULL, phi=NULL,
initial=c("optimal","backcasting"), initialSeason=NULL, ic=c("AICc","AIC","BIC","BICc"),
loss=c("likelihood","MSE","MAE","HAM","MSEh","TMSE","GTMSE","MSCE"),
h=10, holdout=FALSE, cumulative=FALSE,
interval=c("none","parametric","likelihood","semiparametric","nonparametric"), level=0.95,
bounds=c("usual","admissible","none"),
silent=c("all","graph","legend","output","none"),
xreg=NULL, regressors=c("use","select"), initialX=NULL, ...){
注意到它实际上是
es_old
?在提交2d28169中,消息显示为
新的 es() 函数,基于 adam()。旧的保留在 es_old() 名下
如果我们寻找新的“真实”
es()
函数声明,我们会在smooth/R/es-adam.R
中找到它,并注意到silent=
已从上面的字符串选项更改为类logical
。
es <- function(y, model="ZZZ", lags=c(frequency(y)), persistence=NULL, phi=NULL,
initial=c("optimal","backcasting","complete"), initialSeason=NULL, ic=c("AICc","AIC","BIC","BICc"),
loss=c("likelihood","MSE","MAE","HAM","MSEh","TMSE","GTMSE","MSCE"),
h=10, holdout=FALSE,
# cumulative=FALSE,
# interval=c("none","parametric","likelihood","semiparametric","nonparametric"), level=0.95,
bounds=c("usual","admissible","none"),
silent=TRUE,
xreg=NULL, regressors=c("use","select"), initialX=NULL, ...){
(https://github.com/config-i1/smooth/blob/master/R/adam-es.R#L232)
环顾四周
smooth
,它使用了silent
,就好像逻辑一样(例如,https://github.com/config-i1/smooth/blob/master/R/es.R#L700) ,所以看来该包内部是一致的。
因此,该错误似乎仅存在于
MAPA
中,因为它们尚未适应新的参数语法。 (虽然我内心有些想把一些责任归咎于 smooth
将一个显而易见的参数从 character
更改为 logical
……我可以想象其他方法来更优雅地处理 API 中如此大的变化。如果我维护MAPA
,我会添加一些逻辑,以便 CRAN 的 revdep 测试能够发现这个问题。)