rtime-seriesforecastingsmoothingstate-space

When ets() is used, why R is not responding and crashes?


I am trying to find the best model to forecast the average monthly rainfall of a particular region. So far I have used a a seasonal naive method and SARIMA. But when trying to run ets(), R crashes without producing an output.


Solution

  • I tend to use fable and fabletools. The followup of forecast. Using package fpp3 loads all the needed packages for working with tsibbles, dplyr and date objects.

    I don't have any issues running any forecasts methods on your data. I tried both fable and forecast and get the same outcomes. See code below.

    # load your data
    df1 <- readxl::read_excel("datasets/Copy.xlsx")
    colnames(df1) <- c("date", "rainfall")
    
    
    library(fpp3)
    fit <- df1 %>% 
      mutate(date = yearmonth(date)) %>%
      as_tsibble() %>% 
      model(ets = ETS(rainfall)) 
      
    report(fit)
    
    Series: rainfall 
    Model: ETS(M,N,A) 
      Smoothing parameters:
        alpha = 0.002516949 
        gamma = 0.0001065384 
    
      Initial states:
        l[0]      s[0]     s[-1]     s[-2]    s[-3]    s[-4]    s[-5]    s[-6]     s[-7]     s[-8]     s[-9]    s[-10]
     86.7627 -77.53686 -57.90353 -18.72201 86.57944 150.0896 166.8125 60.45602 -39.25331 -55.94238 -68.85851 -70.52719
        s[-11]
     -75.19377
    
      sigma^2:  0.1109
    
         AIC     AICc      BIC 
    2797.766 2799.800 2850.708
    

    Using forecast:

    library(forecast)
    fit <- forecast::ets(ts(df1[, 2], frequency = 12))
    
    fit
    
    ETS(M,N,A) 
    
    Call:
     forecast::ets(y = ts(df1[, 2], frequency = 12)) 
    
      Smoothing parameters:
        alpha = 0.0025 
        gamma = 1e-04 
    
      Initial states:
        l = 86.7627 
        s = -77.5369 -57.9035 -18.722 86.5794 150.0896 166.8125
               60.456 -39.2533 -55.9424 -68.8585 -70.5272 -75.1938
    
      sigma:  0.333
    
         AIC     AICc      BIC 
    2797.766 2799.800 2850.708