mapa Multiple Aggregation Prediction Algorithm (Wrapper)
I want to use the mapa function in the MAPA package, everything works, and I mean everything, it does produces forecasts if I leave type empty.
But using:
type = 'es'
Produces an error, I don't know why since the documentation says that:
<<type What type of exponential smoothing implementation to use. "es" = use from the smooth package; "ets" = use from the forecast package. Default is "es" >>
https://cran.r-project.org/web/packages/MAPA/MAPA.pdf
Using type = 'ets' works fine, or just dont adding that parameter. I wanted to use xreg, but can't since it forces type type = 'es', thus producing the error.
> 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
This is the error
> mapa(ts(c(1:80), frequency = 1), type = 'es', outplot = 1)
Error in !silent : invalid argument type
I have already re installed both MAPA and smooth packages.
devtools::install_github("config-i1/smooth")
devtools::install_github("trnnick/mapa")
This appears to be a bug.
mapa::mapa
calls
# 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)
So far fine, but if we look at smooth/R/es.R
, we see that the function declaration is
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, ...){
Notice that it is actually es_old
? In commit 2d28169, the message reads
New es() function, based on adam(). The old one is kept under the name of es_old()
If we look for the new "real" es()
function declaration, we find it in smooth/R/es-adam.R
, and notice that silent=
has changed from the string option of above to class 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)
Looking around smooth
some more it is using silent
as is if were logical (e.g., https://github.com/config-i1/smooth/blob/master/R/es.R#L700), so it appears that that package is consistent internally.
So it appears that the bug is solely in MAPA
in that they have not adapted to the new argument syntax. (Though part of me wants to throw some blame on smooth
for changing a not-obscure argument from character
to logical
... I can imagine other ways to more gracefully deal with such a large change in the API. If I were maintaining MAPA
, I'd add some logic so that revdep-tests at CRAN would have caught this problem.)