1

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.

noob
  • 13
  • 5
  • If R is not responding the etc call is still running. Without your data it is difficult to see whether or not there is an issue. – phiver Nov 01 '21 at 10:26
  • @phiver how shall i attach the data here? – noob Nov 01 '21 at 11:24
  • Either load the data in your github or share the source link. Rainfall should come from one the weather providers like noaa, dwd, knmi or the metoffice – phiver Nov 01 '21 at 11:39
  • @phiver https://github.com/noob-mun/Rainfall-data/blob/main/Copy.xlsx – noob Nov 01 '21 at 17:24

1 Answers1

2

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 
phiver
  • 23,048
  • 14
  • 44
  • 56
  • the same issue still persists. I tried running the code and then R is not responding and crashed. Perhaps it got to do with the system I use. Can the reason as to why R crashes when I run `ets()` or `hw()` be that my system doesn't support it? – noob Nov 02 '21 at 13:01
  • @noob, There shouldn't be a reason unless there is an issue with your memory. Have you tried running in the R console and not using Rstudio or any other ide? – phiver Nov 03 '21 at 10:49
  • 1
    I have been running it in R console and not in Rstudio. But then I tried it in the Jupyter Notebook and got the output. – noob Nov 03 '21 at 12:04