@@ -140,16 +140,11 @@ estimate_ets <- function(y, m, init.state, errortype, trendtype, seasontype,
140140 alpha = unname(alpha ), beta = unname(beta ),
141141 gamma = unname(gamma ), phi = unname(phi ), init.state
142142 )
143- if (errortype == " A" ) {
144- fits <- y - e $ e
145- } else {
146- fits <- y / (1 + e $ e )
147- }
148143
149144 return (list (
150145 loglik = - 0.5 * e $ lik , aic = aic , bic = bic , aicc = aicc ,
151146 mse = mse , amse = amse , mae = mae ,
152- residuals = e $ e , fitted = fits ,
147+ residuals = e $ e , fitted = e $ fits ,
153148 states = states , par = fit.par
154149 ))
155150}
@@ -429,7 +424,7 @@ pegelsresid.C <- function(y, m, init.state, errortype, trendtype, seasontype, da
429424 p <- length(init.state )
430425 x <- numeric (p * (n + 1 ))
431426 x [1 : p ] <- init.state
432- e <- numeric (n )
427+ e <- fits <- numeric (n )
433428 lik <- 0
434429 if (! damped ) {
435430 phi <- 1
@@ -457,18 +452,15 @@ pegelsresid.C <- function(y, m, init.state, errortype, trendtype, seasontype, da
457452 as.double(gamma ),
458453 as.double(phi ),
459454 as.double(e ),
455+ as.double(fits ),
460456 as.double(lik ),
461457 as.double(amse ),
462458 as.integer(nmse ),
459+ NAOK = TRUE ,
463460 PACKAGE = " fable"
464461 )
465- if (! is.na(Cout [[13 ]])) {
466- if (abs(Cout [[13 ]] + 99999 ) < 1e-7 ) {
467- Cout [[13 ]] <- NA
468- }
469- }
470462
471- return (list (lik = Cout [[13 ]], amse = Cout [[14 ]], e = Cout [[12 ]], states = matrix (Cout [[3 ]], nrow = n + 1 , ncol = p , byrow = TRUE )))
463+ return (list (lik = Cout [[14 ]], amse = Cout [[15 ]], e = Cout [[12 ]], fits = Cout [[ 13 ]], states = matrix (Cout [[3 ]], nrow = n + 1 , ncol = p , byrow = TRUE )))
472464}
473465
474466admissible <- function (alpha , beta , gamma , phi , m ) {
0 commit comments