STL 在纯 AR(2) 过程中检测季节性

问题描述 投票:0回答:1

我在 R 中模拟了纯 AR(2) 过程。当我从盛宴包中运行

STL
(Loess 的季节性分解)时,该函数检测到很强的季节性。数据生成过程有任何季节性。

如何调整

STL
中的参数以避免检测到虚假的季节性。

library(fable)
library(fabletools)
library(tsibble)
library(tsibbledata)
library(lubridate)
library(dplyr)
library(tidyr)
library(feasts)


# simulate an ar2 process
set.seed(0)
sd_epilson = 0.5

data = rnorm(500)

for (i in 3:500){
  data[i] = 10 + 0.5*data[i-1] + 0.3*data[i-2] + rnorm(1, 0, sd_epilson)
}

data = tail(data, 400)

ts_data = ts(data, start=c(1970,1), frequency=12) %>%
  as_tsibble()

train = ts_data[1:360,]
test = ts_data[361:384,]

# model with STL()
train %>% 
  model(
    stl = STL(value)
    )  %>% 
  components()  %>% 
  autoplot()

我的会议信息:

R version 4.2.3 (2023-03-15 ucrt)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 22635)

Matrix products: default

locale:
[1] LC_COLLATE=English_United States.utf8  LC_CTYPE=English_United States.utf8   
[3] LC_MONETARY=English_United States.utf8 LC_NUMERIC=C                          
[5] LC_TIME=English_United States.utf8    

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

other attached packages:
 [1] purrr_1.0.2       furrr_0.3.1       future_1.33.1     feasts_0.3.1      tidyr_1.3.0       dplyr_1.1.4      
 [7] lubridate_1.9.3   tsibbledata_0.4.1 tsibble_1.1.3     fable_0.3.3       fabletools_0.3.4 

loaded via a namespace (and not attached):
 [1] Rcpp_1.0.11          progressr_0.14.0     pillar_1.9.0         compiler_4.2.3       tools_4.2.3         
 [6] digest_0.6.33        lifecycle_1.0.4      tibble_3.2.1         gtable_0.3.4         anytime_0.3.9       
[11] timechange_0.2.0     pkgconfig_2.0.3      rlang_1.1.2          cli_3.6.2            rstudioapi_0.15.0   
[16] parallel_4.2.3       xfun_0.41            withr_2.5.2          knitr_1.45           globals_0.16.2      
[21] generics_0.1.3       vctrs_0.6.5          rappdirs_0.3.3       grid_4.2.3           tidyselect_1.2.0    
[26] glue_1.6.2           listenv_0.9.0        R6_2.5.1             future.apply_1.11.1  parallelly_1.36.0   
[31] fansi_1.0.6          distributional_0.3.2 ggplot2_3.4.4        farver_2.1.1         magrittr_2.0.3      
[36] codetools_0.2-19     scales_1.3.0         ellipsis_0.3.2       colorspace_2.1-0     labeling_0.4.3      
[41] utf8_1.2.4           munsell_0.5.0  
r forecasting forecast fable-r fabletools
1个回答
0
投票

STL 不检测季节性。您要求它对年度季节性进行建模,它确实如此。如果你只是想估计一个趋势,那就不要使用STL。

© www.soinside.com 2019 - 2024. All rights reserved.