[英]in R, how to capture ARIMA elements from auto.arima results
I have a bunch of series to forecast using forecast::auto.arima function.我有一堆系列要使用 forecast::auto.arima 函数进行预测。 I like to save what type of model did auto.arima fit.我喜欢保存 auto.arima 适合的模型类型。 If you run the following code:如果您运行以下代码:
library(forecast)
set.seed(123)
y <- sin(seq(-pi,pi,0.05))+(rnorm(length(seq(-pi,pi,0.05)))/4)
arima.model <- auto.arima(y)
arima.model华宇模型
the result of the last line execution shows最后一行执行的结果显示
Series: y
**ARIMA(1,1,2)**
Coefficients:
ar1 ma1 ma2
0.9594 -1.7285 0.7740
s.e. 0.0380 0.0745 0.0658
sigma^2 estimated as 0.06534: log likelihood=-6.1
AIC=20.2 AICc=20.53 BIC=31.51
How can I capture ARIMA(1,1,2) and save results?如何捕获 ARIMA(1,1,2) 并保存结果? I was hoping to do something like arima.model$
and capture what I need to but I could not figure it out.我希望做类似arima.model$
的事情并捕获我需要的东西,但我无法弄清楚。
You can try summary(arima.model)
, arima.model$coef
, arima.model$aic
, arima.model$bic
.您可以尝试summary(arima.model)
、 arima.model$coef
、 arima.model$aic
、 arima.model$bic
。
If you want a tidy format, you can use broom package like this:如果你想要一个整洁的格式,你可以像这样使用 broom 包:
library(broom)
tidy(arima.model) #ar/ma terms
glance(arima.model) #information criteria
tidy(arima.model)
# A tibble: 3 x 3
term estimate std.error
<fct> <dbl> <dbl>
1 ar1 0.959 0.0380
2 ma1 -1.73 0.0745
3 ma2 0.774 0.0658
glance(arima.model)
# A tibble: 1 x 4
sigma logLik AIC BIC
<dbl> <dbl> <dbl> <dbl>
1 0.256 -6.10 20.2 31.5
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.