1

I have about 100 ARIMA models, where each models the demand of a separate household using the temperature as an exogenous value. I've used the auto.arima from the forecast package on R and used xreg to input the temperature.

Now I changed/simulated several series of temperature values and want to use the new temperature values to recalculate the demand using the previously constructed ARIMA model.

I think I can calculate the values manually by referring to each coefficient value of the model. However, it will be inefficient as I have more than 100 models.

Is there a more efficient way to get this done?

So far my code is

arima_model = 
    auto.arima(sqrt(house_data$demand), 
    xreg = as.matrix(house_data$temp)) 
    # model for demand
temp_auto_arima = auto.arima(house_data$temp) 
    # model for the temperature
new_temperature = simulate(temp_auto_arima) 
    # simulate temperature to get a new series 

1 Answers1

1

You can use simulate(arima_model, xreg = new_x) with a the parameter xreg to simulate a time series with a different regressor vector or matrix.

Below is an example

enter image description here

### generate data
set.seed(1)
t = c(1:1000)
x = sin(t/1000*2*pi*3)
noise = arima.sim(n = 1000, list(ar = c(0.2,-0.5), ma = c(1,0.5)),
                  sd = 0.1)

plot time series

demand = x + noise plot(t,demand, main = "black: original model \n red: simulate(mod, xreg = new_x)")

model time series and plot newly generated series

arima_model = auto.arima(y, xreg = x) new_x = sin(t/10002pi*3+pi) points(t,simulate(arima_model , xreg = new_x), col = 2) mod

  • @Thusitha Was this the issue? Or do you not want to change the noise in the newly simulated demand time series and only change the time but keep the same arima noise? – Sextus Empiricus May 02 '22 at 07:21
  • Thank for the answer. However, what I want to do is instead of simulating the demand arima model, recalculate the demand values using the model with simulated temperature – Thusitha Thilina Dayaratne May 02 '22 at 07:43
  • I don't want to simulate the demand. I simulate the temperature and want to use that temperature to calculate the demand using the already constructed ARIMA model – Thusitha Thilina Dayaratne May 02 '22 at 07:46
  • @ThusithaThilinaDayaratne the model is not recalculated, with simulate you use the already constructed arima model (the estimated parameters). Only the particular realization of the noise terms are recomputed/resimulated. Is that what you mean by 'I don't want to simulate'? – Sextus Empiricus May 02 '22 at 08:09
  • @ThusithaThilinaDayaratne if you show the manual method then it becomes clear what you want to do. – Sextus Empiricus May 02 '22 at 08:13
  • I'm referring to manually calculate as in https://stats.stackexchange.com/questions/266967/manual-calculation-of-arima1-1-0-forecast – Thusitha Thilina Dayaratne May 03 '22 at 10:41
  • if I use simulate function, it simulates the demand. But instead of simulating the demand, I want to only simulate the temperature and then use that to calculate demand values using the obtained ARIMA model – Thusitha Thilina Dayaratne May 03 '22 at 10:42