0

我会拟合一个SARIMAX以温度为外生变量的模型R。我可以使用 中xreg存在的功能来做到这一点package TSA吗?我认为将模型拟合为:

fit1 = arima(x, order=c(p,d,q), seasonal=list(order=c(P,D,Q), period=S), xreg=temp)

这是正确的还是我必须使用其他功能R?如果它不正确:我应该使用哪些步骤?

谢谢。

4

2 回答 2

2

查看预测包,它很棒:

   # some random data
   x <- ts(rnorm(120,0,3) + 1:120 + 20*sin(2*pi*(1:120)/12), frequency=12)
   temp = rnorm(length(x), 20, 30)

   require(forecast)
   # build the model (check ?auto.arima)
   model = auto.arima(x, xreg = data.frame(temp = temp))

   # some random predictors
   temp.reg = data.frame(temp = rnorm(10, 20, 30))

   # forecasting
   forec = forecast(model, xreg = temp.reg)

   # quick way to visualize things
   plot(forec)

  # model diagnosis
  tsdiag(model)

  # model info
  summary(forec)
于 2013-07-23T17:24:14.180 回答
0

I won't suggest you to use auto.arima(). Depending on the model you want to fit it may return poor results, as for example when working with some complex SARIMA models the difference between the models done manually and with auto.arima() were noticeable, auto.arima() do not even returned white noise innovations (as it is expected), while manual fits, of course, did.

于 2014-03-12T12:42:11.943 回答