1
$\begingroup$

Assume following data set representing each month of the year 2013 with the corresponding consumption of natrual gas to heat my flat and the respective mean temperature.

How can I seasonal adjust/normalize this time series?


1   156 m³  1,4 °C
2   199 m³  0,3 °C
3   173 m³  2,3 °C
4   69 m³   9,6 °C
5   63 m³   12,2 °C
6   9 m³    16,9 °C
7   9 m³    20,8 °C
8   9 m³    18,5 °C
9   15 m³   14,3 °C
10  19 m³   11,4 °C
11  83 m³   5,2 °C
12  62 m³   4,2 °C

I would like to take into account that it is colder in winter and warmer in summer and know if I needed more or less energy in comparison. (especially in terms of comparing with the year 2014 for example)

I know how to use R, if that makes it easier for you to explain.

$\endgroup$
  • $\begingroup$ How many years data have you got? $\endgroup$ – Peter Flom Jul 2 '14 at 19:27
  • $\begingroup$ 2013 and 2014 so far, but I think about to build a web app where everyone can enter his/her data $\endgroup$ – greg121 Jul 2 '14 at 19:28
  • 3
    $\begingroup$ Your use of the word "seasonal" might confuse people who are used to using it in a technical time-series sense. In your case what you are looking for merely has an accidental relationship to a periodic "season": you want to develop a model that relates heating needs to temperature and use that to assess whether your energy consumption is going down or up after controlling for the temperatures. Having said that, I'll admit that there is a truly seasonal effect lurking here but it won't be possible to find it until such a model is developed. (I use one for my own house.) $\endgroup$ – whuber Jul 2 '14 at 20:03
  • $\begingroup$ Since I have only little experience in statistics I was also wondering if this even is the correct term to describe my problem $\endgroup$ – greg121 Jul 2 '14 at 20:59
  • 1
    $\begingroup$ Using technically correct terms is not really your responsibility. We're here to help you communicate your problem. If you know the terminology, that's great--use it--but if you're unsure, then please do your best to use language you understand to explain to us what you need. I believe you've already done pretty well in this case but I wanted to alert readers who might pick up on the "seasonal adjustment" phrase and potentially misunderstand what you're looking for. $\endgroup$ – whuber Jul 2 '14 at 21:03
3
$\begingroup$

Two observations per month is not much information to carry out seasonal adjustment.

While you gather more data, you may be interested in measuring how consumption changes with temperature. For that, you can fit the following model (a quadratic relationship between consumption and temperature seems appropriate at first glance but see comment by whuber below):

cons <- structure(c(156, 199, 173, 69, 63, 9, 9, 9, 15, 19, 83, 62), .Tsp = c(1, 
  1.91666666666667, 12), class = "ts")
temp <- structure(c(1.4, 0.3, 2.3, 9.6, 12.2, 16.9, 20.8, 18.5, 14.3, 
  11.4, 5.2, 4.2), .Tsp = c(1, 1.91666666666667, 12), class = "ts")

fit <- lm(c(cons) ~ poly(c(temp), 2))
summary(fit)
#Residuals:
#    Min      1Q  Median      3Q     Max 
#-52.340  -7.920  -2.102  17.963  34.661 
#Coefficients:
#                  Estimate Std. Error t value Pr(>|t|)    
#(Intercept)         72.167      7.451   9.686 4.66e-06 ***
#poly(c(temp), 2)1 -201.911     25.810  -7.823 2.65e-05 ***
#poly(c(temp), 2)2   69.987     25.810   2.712   0.0239 *  
#---
#Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
#Residual standard error: 25.81 on 9 degrees of freedom
#Multiple R-squared:  0.8839,   Adjusted R-squared:  0.8582 
#F-statistic: 34.28 on 2 and 9 DF,  p-value: 6.18e-05

Display observed data (black points) and fitted values (in blue):

plot(c(temp), c(cons), pch = 16)
lines(c(sort(temp)), predict(fit)[order(temp)], type = "b", col = "blue")

Upon this regression you can obtain the predicted value for consumption given for example temperatures of 5 and 15 Celsius degrees (along with 95% confidence intervals).

p <- predict(fit, newdata = data.frame(temp = c(5, 15)), se.fit = TRUE)
res <- cbind(p$fit - 1.96 * p$se, p$fit, p$fit + 1.96 * p$se)
colnames(res) <- c("lower limit", "pred", "upper limit")
res
#  lower limit     pred upper limit
#1   83.072304 102.5629   122.05356
#2   -5.487951  14.9201    35.32816

As you obtain more data you can think of further methods. See, for instance, the documentation and examples for function decompose. You could also include seasonal dummies in the above regression. These dummies are indicator variables pointing each one to observations recorded at a given month, e.g. [1 0 0 0 0 0 0 0 0 0 0 0], [0 1 0 0 0 0 0 0 0 0 0 0] and so on. (Note: one of the the 12 seasonal dummies should be omitted in the regression if an intercept is included.)

$\endgroup$
  • 2
    $\begingroup$ If you contemplate how heating actually works, you would modify your model and find it can be a much better fit. There will be a temperature threshold above which no heating takes place: that needs to be explicitly in the model (which makes its fitting a nonlinear regression exercise). For temperatures near that threshold, some heating will occur due to daily variations in temperature: this causes the apparent quadratic effect, but it's localized near the threshold temperature. When you account for these in your model, I expect you will find little or no need to introduce seasonal dummies. $\endgroup$ – whuber Jul 2 '14 at 20:17
  • 2
    $\begingroup$ @whuber Very interesting. Knowing the context of the data is always helpful to propose a good model. $\endgroup$ – javlacalle Jul 2 '14 at 20:58
2
$\begingroup$

In your example, you have less than three observations per month, i.e. you only have one value for January, one for February, etc. In a case with less than three per month, you cannot perform established seasonal adjustment methods such as X-13ARIMA-SEATS by the US Census Bureau. In order to apply X-13ARIMA-SEATS you need at least three observations per month, i.e. you need a time series that is at least three years long. In case you do not have three years of data, you could do year over year comparison.

In your case, you should have more than three years of data by now. Hence, you could perform X-13ARIMA-SEATS. The following site introduces seasonal adjustment:

https://economictheoryblog.com/2017/05/02/seasonal-adjustment

Furthermore, and relevant for your case, I guess, the site provides a hands-on example of how to perform seasonal adjustment in R:

https://economictheoryblog.com/2017/05/16/seasonal-adjustment-in-r

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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