Time series regression example

The data for weekly sales (in thousands of units) of a certain brand at a major US supermarket chain over a year as a function of the price each week.

Sales – weekly sales

Price – weekly price

Week – week of the year

Promostion – 0 (no promotion); 1 (advertised price reduction)

Linear Model (OLS)

  • Box-Cox: \(\lambda=1\) is within 95% CI
  • interactions are not significant
## 
## Call:
## lm(formula = log(Sales) ~ log(Price) + Week + Promotion)
## 
## Residuals:
##      Min       1Q   Median       3Q      Max 
## -0.83116 -0.15094  0.01751  0.14975  0.72786 
## 
## Coefficients:
##              Estimate Std. Error t value Pr(>|t|)    
## (Intercept)  4.739296   0.179463  26.408  < 2e-16 ***
## log(Price)  -4.102794   0.474862  -8.640 2.42e-11 ***
## Week         0.012575   0.002745   4.581 3.31e-05 ***
## Promotion1   0.719451   0.177235   4.059 0.000181 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.2849 on 48 degrees of freedom
## Multiple R-squared:  0.8408, Adjusted R-squared:  0.8309 
## F-statistic: 84.51 on 3 and 48 DF,  p-value: < 2.2e-16

## 
##  Durbin-Watson test
## 
## data:  sales.lm
## DW = 0.91085, p-value = 3.126e-06
## alternative hypothesis: true autocorrelation is not 0

AR(1) regression (GLS)

\[ \epsilon_i=\phi~ \epsilon_{i-1}+z_i,\;\;\;z_i \sim N(0,\sigma^2),\; i.i.d. \]

## Generalized least squares fit by maximum likelihood
##   Model: log(Sales) ~ log(Price) + Week + Promotion 
##   Data: NULL 
##        AIC     BIC   logLik
##   6.537739 18.2452 2.731131
## 
## Correlation Structure: AR(1)
##  Formula: ~Week 
##  Parameter estimate(s):
##       Phi 
## 0.5503593 
## 
## Coefficients:
##                 Value Std.Error   t-value p-value
## (Intercept)  4.675667 0.2383703 19.615142   0.000
## log(Price)  -4.327391 0.5625564 -7.692368   0.000
## Week         0.012517 0.0046692  2.680813   0.010
## Promotion1   0.584650 0.1671113  3.498565   0.001
## 
##  Correlation: 
##            (Intr) lg(Pr) Week  
## log(Price)  0.807              
## Week       -0.625 -0.157       
## Promotion1  0.559  0.682 -0.206
## 
## Standardized residuals:
##        Min         Q1        Med         Q3        Max 
## -2.9473082 -0.6095076  0.1031472  0.5769989  2.9558179 
## 
## Residual standard error: 0.2740294 
## Degrees of freedom: 52 total; 48 residual