2

I am trying to fit a dynamic regression model using auto.arima. I have monthly data for gas (for heating) use per customer (which I want to predict) and set of regressors (e.g. heating degree days, gas price, structural dummies for particular years and seasonal dummies). I have forecast values for the exogenous regressors. Use per customer data is available from Jan 2005- Mar2018, all other data is from Jan2005-Dec 2021. I am trying to forecast Use Per Customer for all months of the year 2020. I am unsure how to divide my data between xreg in the auto.arima function and the forecast function. The forecast values I am currently yielding do not match up with the month of use, for example, April 2018 forecast for use per customer is as high as and almost equal to Jan 2005 actual use. This should not be the case.

I am trying to forecast gas usage for residential customers using a dynamic regression model in the forecats package. I have referred to the online textbook by Prof. Rob J. Hyndman https://otexts.com/fpp2/forecasting.html

#I generated the time series for the period for which the data is available (Jan 2005-Mar 2018)
Med_ros_upc.ts.test<-ts(Med_ros_upc.ts[,"ORMEDSCH410upc.r"], 
frequency    = 12, start = c(2005,1), end = c(2018,3))                        
#This is the set of external regressors including seasonal dummies(sd.ts)
xreg_Med<- cbind(Hdd = Med_ros_upc.ts[, "MEDHDD"],
             Hdd2 = Med_ros_upc.ts[, "MEDHDD2"],
             RPA = Med_ros_upc.ts[, "ORSCH410RPAt1.r"],  sd, 
             Jan2009, intdummf)
#I convert the xreg matrix into a time series. I use this in auto.arima
xreg_Med.ts<-ts(xreg_Med, frequency = 12, start = c(2005,1), 
end = c(2018,3))
#I generate a different xreg for forecast"
xreg_Med.ts1<-ts(xreg_Med, frequency = 12, start = c(2018,4),
 end = c(2021, 12))
fitdyn <- auto.arima(Med_ros_upc.ts.test, xreg =xreg_Med.ts)
fcast <- forecast(fitdyn , xreg = xreg_Med.ts1)

Expected result Point forecast
Jan 2005 111.19 Feb 2005 89.22... April 2005 53.86

Actual result Point forecast

April 2018 111.19 May 2018 89.22... Jun 2018 53.86

4

2 回答 2

0

谢谢!这就是我所做的:

`fitdyn <- auto.arima(Med_ros_upc.ts[,"ORMEDSCH410upc.r"], xreg =xreg_Med, stationary= TRUE)`
`fit<-fitted(fitdyn)`
`fcast_fit<-forecast(fit, h=36, xreg= xreg_Med)`

现在我有两个单独的表,一个带有拟合值和预测值,这些值看起来还不错。

但是,我收到此错误消息:

etsmodel 中的错误(y,errortype[i],trendtype[j],seasontype[k],damped[l],:未使用的参数(xreg = xreg_Med)另外:警告消息:在 ets(object,lambda = lambda,biasadj =biasadj,allow.multiplicative.trend =allow.multiplicative.trend,:遇到缺失值。使用时间序列的最长连续部分

这是否意味着我获得的预测没有考虑外部回归变量?

于 2019-04-29T16:08:06.597 回答
0

您的训练数据从 2005 年 1 月开始,到 2018 年 3 月结束。因此,您的预测从 2018 年 4 月开始。根据定义,预测是训练数据的未来。

于 2019-04-25T22:07:31.820 回答