Hello. I was trying to run a holt() function in my R code and the following error occured:
Error in ets(x, "AAN", alpha = alpha, beta = beta, phi = phi, damped = damped, :
No model able to be fitted.
I've tried multiple efforts to make this code run, but it never did. This is the code that I am trying:
It worked fine for me, as shown in the reprex (reproducible example) below. Also, two bits of advice. First, if you want help, make it easy for us to try your code on your data. After creating a data set with your numbers, I used the dput( ) function to get it in a format that can be easily shared. Second, avoid the use of attach( ). From the Google R Style Guide, "The possibilities for creating errors when using attach( ) are numerous."
library(forecast)
#> Registered S3 method overwritten by 'quantmod':
#> method from
#> as.zoo.data.frame zoo
input <- structure(list(CalSales = c(197L, 211L, 203L, 247L, 239L, 269L,
308L, 262L, 258L, 256L, 261L, 288L, 296L, 276L, 305L, 308L, 356L,
393L, 363L, 386L, 443L, 308L, 358L, 384L)), class = "data.frame", row.names = c(NA,
-24L))
holt_model <- holt(input$CalSales, h=4)
summary(holt_model[["model"]])
#> Holt's method
#>
#> Call:
#> holt(y = input$CalSales, h = 4)
#>
#> Smoothing parameters:
#> alpha = 1e-04
#> beta = 1e-04
#>
#> Initial states:
#> l = 199.7736
#> b = 7.9699
#>
#> sigma: 33.2374
#>
#> AIC AICc BIC
#> 250.0740 253.4073 255.9643
#>
#> Training set error measures:
#> ME RMSE MAE MPE MAPE MASE
#> Training set -0.4254659 30.34144 23.29228 -1.067513 7.490028 0.7730483
#> ACF1
#> Training set 0.1562895