Take the 2-minute tour ×
Cross Validated is a question and answer site for people interested in statistics, machine learning, data analysis, data mining, and data visualization. It's 100% free, no registration required.

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?

share|improve this question
    
You seem to be describing an "intervention analysis" or "interrupted time series" as discussed by @mb3041023. –  RioRaider Nov 15 '12 at 5:04

1 Answer 1

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.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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