3
$\begingroup$

I have hourly utility bills for two years. The first year's data are from before a retrofit was performed on a home and the second year is after the retrofit was performed.

How do I compare the two time series statistically to make claims of demand savings during a specific time period of the day. Can this be done in R, if so how?

$\endgroup$
1
  • $\begingroup$ You seem to be describing an "intervention analysis" or "interrupted time series" as discussed by @mb3041023. $\endgroup$
    – RioRaider
    Nov 15, 2012 at 5:04

1 Answer 1

2
$\begingroup$

You can fit an intervention model in R. This is simply a regression with ARIMA errors. The regression variables measure the effect of interest and the ARIMA errors take care of the serial correlations.

If you assume that the retrofit results in a level shift in demand costs, then the following code will fit the model. Assume that the data is stored in x which is a ts object with frequency 24

library(forecast)
z <- numeric(length(x))
z[(365*24+1):length(x)] <- 1
fit <- auto.arima(x, xreg=z)

The coefficient of z will give you the estimated effect of average demand savings per hour.

If you want a different effect for different times of the day, then try the following.

z <- seasonaldummy(x)
z <- cbind(z,1-rowSums(z))
z[1:(365*24)] <- 0
fit <- auto.arima(x, xreg=z)

Then there will be 24 regression variables representing the 24 hours of the day. The seasonaldummy() function generates 23 dummy variables as you normally don't need the extra one. So the second line creates the missing indicator variable for the 24th hour.

In reality, your data probably have a more complicated seasonal pattern than simply a daily pattern. I imagine there is a day of week effect as well, and probably holiday effects. These can be added in as additional regressors in the above models to control for them.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.