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

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

问题描述

如何检查 ARIMA(p,d,q)中单独的 RMSE 是什么.如果我使用 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 代码:

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函数使用R对时间序列数据使用AR.MA专门检查ARIMA中AR或MA的RMSE值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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