I wish to decompose the trend of the following time series.

enter image description here

The data is as follows,

index = c(96,1492,121,245,95,1621,144,366,158,1679,210,469,194,1796,265,589,305,

It looks like it has both an additive, and a multiplicative component. How do I treat something like this?

  • 4
    $\begingroup$ share your data and we will find out .. $\endgroup$ – IrishStat Nov 14 '17 at 23:44
  • 1
    $\begingroup$ There also seems to be an upward trend. $\endgroup$ – Michael R. Chernick Nov 15 '17 at 3:13
  • 1
    $\begingroup$ Is this actual data, or simulated? If actual, what is it? $\endgroup$ – S. Kolassa - Reinstate Monica Nov 15 '17 at 7:44

The seasonality in this data appears to arise from quarterly variations over time. If you are confident that this is a fixed seasonality (e.g., if the data represent quarterly periods in a year, and you have reason to believe there is an annual seasonal effect in your data) then the simplest way to model this seasonality would be to use a simple model that includes Time as a predictor, but also includes a factor variable for the Quarter.

Example Model - Linear Regression: Here is an example using a linear regression model with these predictors. In this example we use the model:

$$\text{Index} \sim \text{Time} + \text{factor(Quarter)}.$$

This is a very simple model, which treats the seasonality as a separate additive effect and the time-trend as linear. It is a simple starting point for model selection, but can be varied to accommodate more complicated structures.

#Construct the data frame
Index   <- c(96, 1492, 121, 245, 95, 1621, 144, 366, 158, 1679, 
             210, 469, 194, 1796, 265, 589, 305, 1861, 348, 754, 
             403, 1853, 490, 979, 465, 1984, 630);
n       <- length(Index);
Time    <- 1:n;
Quarter <- rep(1:4, length = n);
DATA <- data.frame(Index = Index, Time = Time, Quarter = Quarter);

#Fit a simple linear regression model
MODEL <- lm(Index ~ Time + factor(Quarter), data = DATA);

#Display a plot of the data and fitted line
plot(DATA$Time, DATA$Index, 
     main = 'Plot of Observed and Fitted Values',
     xlab = 'Time', ylab = 'Index', type = 'l');
lines(DATA$Time, MODEL$fitted.values, col = 'red', type = 'l', lty = 3);

enter image description here

Now, we can review the model outputs and the residual plot shown below. As you can see from these outputs, using only four degrees of freedom for the predictors in the model, we still obtain a high goodness-of-fit (Adjusted R-squared = 0.9892). The residual plots show some evidence of non-linearity and heteroskedasticity, so perhaps we could improve the model by also accommodating this with a additional terms. Personally, I would be reluctant to go beyond a simple model here because you only have a small number of values - using a complicated model risks over-fitting. In any case, even with this simple model we already have quite a good fit.

#Review the model outputs:


(Intercept)       -37.463     33.910  -1.105    0.281    
Time               21.739      1.693  12.838 1.08e-11 ***
factor(Quarter)2 1488.261     36.516  40.756  < 2e-16 ***
factor(Quarter)3   26.808     36.634   0.732    0.472    
factor(Quarter)4  300.118     38.004   7.897 7.31e-08 ***

Residual standard error: 68.24 on 22 degrees of freedom
Multiple R-squared:  0.9909,    Adjusted R-squared:  0.9892 
F-statistic: 597.6 on 4 and 22 DF,  p-value: < 2.2e-16


Analysis of Variance Table

Response: Index
                Df   Sum Sq Mean Sq F value    Pr(>F)    
Time             1   782267  782267  167.98 8.935e-12 ***
factor(Quarter)  3 10349378 3449793  740.78 < 2.2e-16 ***
Residuals       22   102453    4657                      

#Display the residual plots
par(mfrow = c(2, 2));

enter image description here


I took your 27 values and obtained the following model enter image description here and here enter image description here and here enter image description here . The residuals suggest sufficiency enter image description here and here enter image description here . The Actual/Fit and Forecast is here enter image description here . The Cleansed and the Actual enter image description here with forecast plot here enter image description here

In summary it is an additive Holt-Winters seasonal model with 3 anomalies ... This is the way I would "decompose" the original series to trend.. seasonal dummies ..and 3 pulses ..leading to an error process free of structure.

In terms of your desire to "decompose the trend" , simply modify/cleanse the three errant/unusual observations using the 3 pulse coefficients and then use the coefficients 256.07 and 20.6019 to adjust the Y values for mean and trend .

Some people (not to mention any names) are often concerned about fitting 8 parameters to 27 values ...so I reran and restricted the solution to not detect any anomalies/pulses. The good news is that only 5 parameters are estimated . The bad news is that the results are unacceptable .enter image description here and a residual plot here enter image description here . Sometimes you have to listen to the data and validate the assumptions under which models are estimated.


Your Answer

