简体   繁体   English

使用 ets() 时,为什么 R 没有响应并崩溃?

[英]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 aa seasonal naive method and SARIMA.到目前为止,我已经使用了季节性天真的方法和 SARIMA。 But when trying to run ets() , R crashes without producing an output.但是当尝试运行ets() ,R 崩溃而不产生输出。

Data collected is for 20 years and the code i used is收集的数据是 20 年,我使用的代码是

Rainfall_ts <- ts(Rainfall[,2], start = c(1990,1), frequency = 12)

fit <- ets(Rainfall_ts) (after running this line the R is not responding)`` fit <- ets(Rainfall_ts) (运行此行后,R 没有响应)``

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.使用包 fpp3 加载处理 tsibbles、dplyr 和 date 对象所需的所有包。

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 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM