如何使用auto.arima函数专门检查ARIMA中AR或MA的RMSE值,用于使用R的时间序列数据 [英] How to specifically check value of RMSE of AR or MA in ARIMA using auto.arima function for time series data using R

查看:96
本文介绍了如何使用auto.arima函数专门检查ARIMA中AR或MA的RMSE值,用于使用R的时间序列数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何检查 RMSE 单独在 ARIMA(p,d,q) 中的内容.如果我像这样用 arima.sim 模拟时间序列数据.

How do I check what the RMSE alone is in ARIMA(p,d,q). If I simulate a time series data with arima.sim like this.

wn <- rnorm(10, mean = 0, sd = 1)
ar <- wn[1:2]
for (i in 3:10){
  ar<-arima.sim(n=10,model=list(ar=-0.7048,order=c(1,1,0)),start.innov=4.1,n.start=1,innov=wn)
}
ar <-ar[-1]

我已经尝试了下面的 r 代码:

I have tried the r code bellow:

mis <- auto.arima(ar)
summary(auto.arima(ar))
mod1 <- auto.arima(ar)
refit <- Arima(ar, model=mod1)
acu<-accuracy(refit)
acu$

我想要一个像 rmse<-function(mis,...) 这样的函数,它只会打印出 RMSE

I want a function like rmse<-function(mis,...) that will print out just the value of RMSE

推荐答案

你只需要 acu[1, 2] 但如果你想要一个函数:

All you need is acu[1, 2] but if you want a function:

library(forecast)
set.seed(100)
wn <- rnorm(10, mean = 0, sd = 1)
ar <- wn[1:2]
for (i in 3:10){
  ar<-arima.sim(n=10,model=list(ar=-0.7048,order=c(1,1,0)),start.innov=4.1,n.start=1,innov=wn)
}
ar <-ar[-1]
ar

mis <- auto.arima(ar)
acu <- accuracy(mis)
acu
#                       ME      RMSE      MAE      MPE  MAPE      MASE      ACF1
# Training set -0.06866332 0.5832581 0.510061 -15.2432 52.34 0.2901498 0.5778458

acu[1, 2]
# [1] 0.5832581

rmse_mis_fun <- function(x) {
  a <- accuracy(x)
  a[1, 2]
}

rmse_mis_fun(mis)
# [1] 0.5832581

能够通过 ar 可能是一个更有用的功能:

being able to pass ar might be a more useful function:

rmse <- function(x) {
  m <- auto.arima(x)
  acu <- accuracy(m)
  acu[1, 2]
}

rmse(ar)
# [1] 0.5832581

这篇关于如何使用auto.arima函数专门检查ARIMA中AR或MA的RMSE值,用于使用R的时间序列数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆