首页 > 解决方案 > R中的ets()函数永远不会停止

问题描述

我试图在我的时间序列中使用 R 中的 ets() 函数,当我运行它时,它永远不会停止。

我知道应该有问题,因为我还尝试了示例练习教授的代码,他应该可以正常工作并遇到同样的问题。R崩溃,我必须关闭它并再次打开。

这就是我的时间序列的样子:

data_ts
Time Series:
Start = c(3, 5) 
End = c(18, 2) 
Frequency = 7 
  [1] 152 100  54 199 166 143 162 116 136  68 176 181 120 141 205 118  62 152 135 180 172 180  82  96 193 209 146 189
 [29] 170  94  67 182 201 186 223 187  96  70 156 220 214 160 180 114  76 194 176 141 194 153 102 128 193 185 173 169
 [57] 171  95  80 137 147 163 183 165  78  88 169 172 169 190 123  76  50 147 126 159 172 162  92  79  99 125 171 182
 [85] 185  98  50 151 188 148 165 167  96  86 244 173 127 124 151 134  96 138 244

这是我正在使用的代码行:

data_ts.ets1 <- ets(data_ts, model = "ANA")

我也尝试了默认模型=“ZZZ”并遇到了同样的问题。在此之前,我在这个时间序列中使用了其他函数(例如 auto.arima())并且效果很好。

我是一名学生,所以我不确定如何继续或从哪里开始解决这个问题。欢迎任何想法

-- Edit1:刚意识到我第一次想尝试运行 ets() 函数时,控制台显示“无法安装模型”。我第二次尝试它,它发生了我之前所说的(运行并且永不停止)

这很奇怪,因为我教授的代码也有同样的问题,他肯定要安装一个模型。

-- Edit2: 尝试使用 forecast::ets 而不是 ets 来运行它并且有同样的问题。还尝试检查我是否有过时的包,但没有

-- 编辑3:

sessionInfo()
R version 4.0.3 (2020-10-10)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 19042)

Matrix products: default

locale:
[1] LC_COLLATE=Spanish_Argentina.1252  LC_CTYPE=Spanish_Argentina.1252    LC_MONETARY=Spanish_Argentina.1252
[4] LC_NUMERIC=C                       LC_TIME=Spanish_Argentina.1252    

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] forecast_8.15   devtools_2.4.2  usethis_2.1.3   ggplot2_3.3.5   dplyr_1.0.7     tseries_0.10-48

loaded via a namespace (and not attached):
 [1] Rcpp_1.0.6        lattice_0.20-41   prettyunits_1.1.1 ps_1.5.0          zoo_1.8-8         rprojroot_2.0.2  
 [7] assertthat_0.2.1  digest_0.6.25     lmtest_0.9-38     utf8_1.1.4        R6_2.5.1          evaluate_0.14    
[13] pillar_1.6.4      rlang_0.4.12      curl_4.3          fracdiff_1.5-1    callr_3.7.0       TTR_0.24.2       
[19] rmarkdown_2.6     desc_1.4.0        labeling_0.4.2    stringr_1.4.0     munsell_0.5.0     compiler_4.0.3   
[25] xfun_0.18         pkgconfig_2.0.3   pkgbuild_1.2.0    urca_1.3-0        htmltools_0.5.0   nnet_7.3-14      
[31] tidyselect_1.1.0  tibble_3.0.3      quadprog_1.5-8    fansi_0.4.2       crayon_1.4.2      withr_2.4.2      
[37] grid_4.0.3        nlme_3.1-149      jsonlite_1.7.2    gtable_0.3.0      lifecycle_1.0.1   DBI_1.1.1        
[43] magrittr_2.0.1    scales_1.1.1      quantmod_0.4.18   cli_3.1.0         stringi_1.5.3     cachem_1.0.6     
[49] farver_2.0.3      remotes_2.4.1     fs_1.5.0          testthat_3.1.0    timeDate_3043.102 ellipsis_0.3.2   
[55] xts_0.12.1        generics_0.1.0    vctrs_0.3.8       tools_4.0.3       glue_1.4.2        purrr_0.3.4      
[61] pkgload_1.2.3     processx_3.5.2    parallel_4.0.3    fastmap_1.1.0     yaml_2.2.1        colorspace_1.4-1 
[67] sessioninfo_1.2.1 memoise_2.0.0     knitr_1.30     

-- 最终编辑:在我更新了 RStudio 中的所有包后,它工作了。不仅是我的代码开头附加的包(如预测包),还有我的 RStudio 中所有过时的包。
所以,不知道为什么,但问题解决了。

标签: rtime-series

解决方案


推荐阅读