I've been attempting to forecast natural gas power demand and how it is affected by temperature and price. I'm not sure if I have done everything correctly (relatively new to R), but I do seem to get relevant data other than I can't seem to change my forecast period, nor am I sure this is an appropriate model for this data. Hopefully someone can provide me with some guidance.
Data: demand.csv
library(forecast)
data = read.csv("demand.csv")
# Create matrix of numeric predictors
xreg <- cbind(weather=data$Weather,price=data$Price,m1=data$M1,
m2=data$M2,m3=data$M3,m4=data$M4,m5=data$M5,m6=data$M6,
m7=data$M7,m8=data$M8,m9=data$M9,m10=data$M10,m11=data$M11)
# Rename columns
colnames(xreg) <- c("Weather","Price","Jan","Feb","Mar","Apr",
"May","Jun","Jul","Aug","Sep","Oct","Nov")
# Variable to be modelled
demandTS <- ts(data$Demand, frequency=12)
# Find ARIMAX model
demandArima <- auto.arima(demandTS, xreg=xreg)
demand.fcast <- forecast(demandArima, xreg=xreg)
plot(demand.fcast)
Thank you for any help.
References:
How to setup xreg argument in auto ARIMA in R From auto ARIMA to forecast in R