Seasonal Variations
-
annual in period
-
e.g. sales figure, temperature reading
-
can readily be estimated if directly interested
-
can be removed from the data if not directly interested
Other Cyclic Variations
-
variatons at fixed period
$~~~$ e.g. daily temperature -
variation not at fixed period, but still predictable
$~~~$ e.g. business cycles of 3 to 4 years or more than 10 years
Trend
-
'long term change in the mean level'
-
need to take into account the number of observation available and make a subjective assessment of what 'long term' means
-
e.g. climate variables: data of 50 years we may see a cyclic variation; while data of 20 years we may only see a trend
Other irregular fluctuation (Residual)
-
after trends and cyclic variations are removed from the data, we will observe the residual that may or may not be 'random'
-
need to analyze if there is any cyclic variation left to be extract, or
-
any irregular variations may be explained in terms of probablity models, such as moving average (MA) or autoregressive (AR)
Stationary: A time series is stationary if there is no systematic change in mean (no trend), if there is no systematic change in variance and if stricly periodic variations has been removed.
- Many theories are concerned with stationary time series. So transform to statsionary if neccessary.
Suggested if: (1) there is a trend; (2) variance is increasing with the mean
-
If the standard deviation is directly proportional to the mean, a logarithm transform is indicated.
-
If the variance changes through time without a trend being present, then a transformation will not help. In such cases, a model that allows for changing variance should be considered.
Suggested if: (1) there is a trend; (2) seasonal effect is increasing with mean
-
if so, suggested to make the seasonal effect constant from year to year. This is refer to as additive seasonal effect.
-
Multiplicative seasonal effect if directly proportional to the mean.
-
A logarithm transformation is suggested to make it additive
-
However, this transform will only stablize the variance if error term is also thought to be multiplicative (see later)
-
Model building and forecasting are usually carried out on the assumption that the data are normally distributed.
-
Difficult. Necessary to model the data using a different 'error' distribution
BOX-COX transformation:
logarithm and square-root are special cases of BOX-COX. Given a time series
Problems in practice:
-
Experiments found little in improvement with BOX-COX transformation
-
Cannot achieve all of the above requirements
-
Hard to 'transform back'
Simplest type of trend, 'linear model + noise': an observaton at time
-
(1.1) is a deterministic function of time and is sometimes called global linear trend, and is generally not practical.
-
More emphasis on models that is locally linear. One possibility is to fit a piecewise linear model.
-
To solve the unsmoothing points in pieceise linear model, we could assume that
$\alpha$ and$\beta$ evolve stochastically, leading to a Stochastic Trend.
General Approaches:
- ** for future updates **
Moving Average
Basic Formula:
$$ y_t = \sum^{+s}{r = -q} a_r x{t+r} \ s.t. \sum a_r = 1 $$
-
Simplest example:
$Sm(x) = \frac{1}{2q+1}\sum_{r = -q}^{q} x_{t+r} $ . Help to removing seasonal variation. -
Symmetric coefficient:
$(\frac{1}{2} + \frac{1}{2})^{2q}$ . When q gets large, approximates to normal curve. -
Spenser's 15-point moving average: used for mortality stats
-
Henderson moving average: cubic polynomial trend without distortion.
end-effects problem: happens when symmetric filter is chosen.
-
Exponential Smoothing:
$$Sm(x) = \sum^\infty_{j=0} \alpha(1-\alpha)^j \ x_{t-j} $$ where
$0 < \alpha < 1$ . Note that$\alpha(1-\alpha)^j$ decreases geometrically with j.
Once we have extimated the trend, we calculate the residual:
$$ \begin{aligned} Res(x_t) &= \text{residual from smmothed value} \ &= x_t - Sm(x_t) \ &= \sum^{s}{r=-q} b_r \ x{t+r} \end{aligned}$$
- This is also a linear filter with
$b_0 = 1 - a_0$ and$b_r = -a_r$ for$r\neq0$ . - If
$\sum a_r = 1$ then$\sum b_r = 0$
A smoothing procedure can be carried out in two or more stages.
It is easy to show that a series of linear operations is still a linear filter:
Suppose filter 1, with weights
where $$ c_k = \sum_r a_r \ b_{k-r} $$
Note that
-
A special type of filtering, particularly useful for removing a trend.
-
For non-seasonal time series, first order is usually sufficient to obtain stationary series.
For a given time series
Occationally second order differencing will be used
Three commonly used seasonal model:
-
$m_t$ is the deseasonalized mean level at time$t$ -
$S_t$ is the seasonal effect at time$t$ -
$\epsilon_t$ is the random error
Note: model C is easy to handel with a logarithm tranformation (to a linear model)
The analysis of time series, which exhibit seasonal variation, depends on whether one wants to:
- measure the seasonal effect and/or
- eliminate seasonality.
For series showing little trend, it is usually adequate to estimaten the seasonal effect for a particular period (e.g. January) by
- the average of each January observation
$-$ the corresponding yearly average in the additive case; - the January observation
$/$ the yearly average in the multiplicative case.
For time series containing a substantial trend:
-
If monthly data, we use this to eliminate seasonal effect
$$Sm(x_t) = \frac{\frac{1}{2}x_{t-6} +x_{t-5}+x_{t-4}+...+x_{t-4}+x_{t-5}+x_{t+6}}{12}$$ Note that: Simple MA of 12 months cannot be used, would not be centered at an interger
$t$ . Simple MA of 13 months cannot be used, end points' weights are counted twice -
If quarterly data, we use this to eliminate seasonal effects $$ Sm(x_t) = \frac{\frac{1}{2}x_{t-2}+x_{t-1}+x_{t}+x_{t+1}+\frac{1}{2} x_{t+2}}{4}$$
-
For 4-weekly data, can use simple MA over 13 successive observation
All these procedure will estimate local (deseasonalized) Series.
The seasonal effect itself = $$ $ or $$ $x_t / Sm(x_t) $ $$ depending on the model.
decoposition example
** see jupyter notebook **
Seasonal Differencing
e.g. for monthly data we can use
- widely used for removing or estimating both trend and seasonal effects
- employs a series of linear filters and adopts a reccursive approach.
- is able to deal with the Calender Effect
- can be used with ARIMA, avoiding end-effect problems
Sample Correlation Coefficient: Given
Notes:
$r \in [-1, 1]$ -
$r$ measures the strength of the linear association between the two variables - if the two variables are independent, then
$r=0$ .
We extend this definition into time series data, to measure whether successive data are correlated.
Sample Autocorrelation Coefficient: Given
where
Notes:
-
$r_1$ measures the correlation between adjacent observations$x_{t-1}$ and$x_t$ . -
Since
$\bar x_{(1)} \simeq \bar x_{(2)}$ , (1.3) can be approximated by $$ r_1 = \frac{\sum_{t=1}^{N-1} (x_t - \bar x)(x_{t+1} - \bar x)}{(N-1) \sum^N_{t=1} (x_t - \bar x)^2 /N} \tag{1.4}$$where
$\bar x = \sum^N_{t = 1} x_t / N$ -
for large
$N$ we can drop$(N-1)/N$ in (1.4) and further approximate$r_1$ as $$ r_1 = \frac{\sum_{t=1}^{N-1} (x_t - \bar x)(x_{t+1} - \bar x)}{\sum^N_{t=1} (x_t - \bar x)^2 } \tag{1.5}$$
Similarly, we define sample correlation correlation at lag k:
Notes:
-
$r_k \in [-1,1]$ , and$r_0 = 1$ -
In practice autocorrelation coefficents are usually calculated by sample autocovariance coefficient at lag k: $$ c_k = \frac{1}{N} \sum_{t=1}^{N-k} (x_t - \bar x)(x_{t+k} - \bar x)$$
and then
$r_k = c_k / c_0$
Correlogram: a plot in which Sample Autocorrelation Coefficient is plotted against lag
- usually
$M \ll N$ . e.g. if$N=200$ , then$M = 20, 30$ - more examples in the next subsection
- if referred to ACF (autocorrelation function) sometimes
A time series is completely random (or i.i.d) if it consists of a series of observations that have the same distribution.
- for large
$N$ , we expect that$r_k \simeq 0$ for positive$k$ . -
$r_k, \ k \ge 0$ is approximately$\mathcal{N}(0, 1/N)$ $$ $\Rightarrow r_k \in [-1.96/\sqrt{N}, +1.96/\sqrt{N}] $ $$ - But one would expect to find one
$r_k$ out of this range ('significant') if e.g.$N = 20$
Short-term correlation is characterized by a farily large value of
If a time series has a tendency to alternate, with successive observations on different sides of the overall mean, then the correlogram also tends to alternate.
-
$r_1$ will natually be negative, while$r_2$ will be positive (observation with lag 2 will tend to be on the same side of the mean)
If a time series has trend, then
- successive observations will be on the same side of the mean due to existence of trends
- little can be inferred from this type of ACF.
- a sample ACF is
${r_k}$ is only meaningful if the time series is stationary. (Any trend should be removed before calculating$r_k$ ) - if the trend is the main interest, it should be modelled rather than removed. In such case correlogram is not helpful.
If a time series contains a seasonal variation, then the correlogram will also exhibit an occilation at the same frequecy. In particular if
for large