The following notes come from the course Time Series Analysis, taught at ETH Zurich by Professor Fadoua Balabdaoui.
Feel free to reach out to me with any comments, clarifications, or corrections.
1. Introduction to Time Series
Time Series DefinitionA time series is a stochastic process indexed by time .
Examples (they are all continuous!):
- : Brownian bridge from to , where the pair notation denotes
- : Brownian motion starting at
- : two-sided Brownian motion
- , or : discrete random walk.
We use the notation to denote a random variable and the notation to denote realizations of that variable.
A time series model is either the specification of:
- all joint distributions (i.e., the model provides for all , , and )
- all their means and covariances for all
White noise
The i.i.d. noise is a sequence of independent and identically distributed random variables such that for all .
In general, we also assume that for all . Note that in this case does not depend on .
Consider such that for all .
If , then:
- (note that and )
is a sequence of centered and uncorrelated random variables. More specifically, , , and for all .
- Note that i.i.d. noise such that is also white noise.
- The term "white" is used by analogy with white light. Indeed, white noise with constant variance has a flat spectral density given by , with (this means that all time-series frequencies are present).
Let be i.i.d. noise such that for all .
is a random walk if and for all .
If is a Rademacher process, then is called a symmetric random walk, with .
Time Series with trend
Let be a zero-mean time series and be a deterministic (non-random) sequence.
Consider for all .
Then is called the trend of .
Time Series with seasonalityGiven a zero-mean time series and a function such that is periodic with known period (i.e., ).
Consider the time series for all . Then is called the seasonal component of .
For example, we could have the seasonal component in the following forms:
with known integers , , and unknown for all .
Time series with both trend and seasonal component
with the trend, the seasonal component, and a zero-mean time series.
StationarityA time series is said to be strictly (strongly) stationary if, for all and , it holds that:
i.e., the stochastic behavior of remains unchanged for any time shift.
Let be a time series.
- The mean function of is defined as:
- The covariance function of is defined as:
provided that and for all .
On the other hand, is said to be (weakly) stationary if for all , and:
- is constant in
- depends only on
1. Week 2
Weak StationarityA time series is said to be weakly stationary if:
- the mean function is constant over time:
- the covariance depends only on
Intuition: Weak stationarity means a series’ average level and dependence pattern stay stable over time.
Note also that the covariance between two time points depends only on their time distance, not on their absolute values (i.e., not on their calendar dates). On the other hand, strict stationarity is a strong concept since the full distribution must be constant over time.
For example, financial prices often show a trend and are not stationary, so we usually work with log returns, such as , which can be closer to weak stationarity and supports tools like ARMA models, autocorrelation analysis, and covariance-based risk estimates.
However, financial returns are not reliable in this sense since volatility clustering, market regimes, and structural breaks can strongly change their distribution.
Given the definition, we can understand why the strict stationarity of implies that all the have the same marginal distribution.
To show this, set . By the definition of strict stationarity, for any lag we have:
Furthermore, since , it follows that for all .
On the other hand, we can now spend some time understanding what a moment means in this context.
In the table below, you can find a summary comparing the first and second moments for single and paired random variables.
We also recall that moments can be generated by the moment-generating function, defined as:
Autocovariance and autocorrelation functions
Let be a stationary time series. The Autocovariance Function (ACVF) at lag is defined as:
Similarly, the Autocorrelation Function (ACF) at lag is defined as:
The second equality holds because, if is stationary, the following hold:
Key Properties of ACVF and ACF
- Boundedness: by the Cauchy–Schwarz inequality, we have that:
Recall that the Cauchy–Schwarz inequality states that, for random variables and with finite second moments:
- Symmetry: since and are even functions (i.e., for all ), for any we have:
If we then set , we have
I.I.D. Noise ProcessLet be an i.i.d. noise process such that and . In this case, we use the notation .
For any , we also have
The zero covariance for is implied by independence.
Furthermore, for all , so the process is stationary, with ACVF and ACF given by:
Also, note that an i.i.d. noise process is also strictly stationary.
White Noise Process
On the other hand, let be a white noise process with variance . In this case, we say if the process satisfies the following:
Note also that the process is stationary with ACVF .
Note that in the case of i.i.d. noise, the are independent and identically distributed, while for white noise we just require uncorrelatedness, zero mean, and finite constant variance (independence is not required!)
Example: Random Walk Process
We recall that is a random walk if and , where .
Also, recall that a random walk has mean zero, , and, for all , we have:
We immediately notice that, since depends on time , the process is not stationary.
We now spend some time computing the autocovariance for a random walk. Consider and , so we have:
The last equality holds because
by independence.
If we also consider the special case , for which , we can conclude that, for all , we have
Secondly, we can do the same for the autocorrelation of a random walk. For all and , we can compute:
We can now characterize the asymptotic behavior of random walk autocorrelation.
- If we fix lag and let , we have stronger correlation as the length of shared history grows:
- If we fix and let , we have weaker correlation for larger time gaps:
First-Order Moving Average Process | MA(1)
Let and . Consider the time series defined as:
Intuition: An MA(1) process combines today's random shock with the previous period's shock , scaled by . The sign of determines whether consecutive shocks reinforce or offset each other.
Given this, we define the mean function as:
Secondly, we can define the autocovariance function (ACVF) of an MA(1) process for all :
The equalities follow from the fact that white noise has zero covariance across different times () and variance at each time. Each indicator marks when two shocks in the expansion are the same shock.
So, since this depends only on the lag , the MA(1) process is stationary, with the following ACVF:
Similarly, we can compute the autocorrelation function of MA(1), given by:
First-Order Autoregressive Process | AR(1)
Let and consider a stationary time series satisfying:
where and for all .
Intuition: The current value is the previous value, scaled by , plus a shock. controls how much of the past carries forward. Note that AR(1) is useful when past values help predict future values, while MA(1) is useful when the dependence comes from recent shocks; these processes will soon be combined in ARMA models.
The mean function of is then:
Since the time series is stationary, we have that . Taking expectations on both sides yields:
But since , we cannot have , so it follows that .
As before, the autocovariance function for AR(1) can be computed as follows for :
Since , according to the condition in the AR(1) definition, , so we write:
However, we still have to compute , which in this case is:
So we can conclude that , which gives .
And, since the function is even, we finally state:
Similarly, the autocorrelation function of AR(1) is simply given by:
3. Sample Estimation and Testing
We now consider to be observations from a stationary time series with:
- sample mean
- sample ACVF at lag given by:
- sample ACF at lag given by:
Note that we divide by and not by to obtain a positive semidefinite matrix.
In particular, let be the centered observation and define, for :
Then build the Toeplitz matrix by setting .
Recall also that "positive semidefinite" means that, for all vectors , we have:
To see the reason, imagine the data outside the observed range (i.e., we only observed , so define for all other integer times). The quadratic form can be written as
which is nonnegative because it is a sum of squares.
Intuition: Using as the denominator preserves the structure and allows the matrix to represent squared combinations of the data.
Note also that, for all time series such that the seasonal component , we can consider the sample estimation of the trend as
Estimation with Two-Sided Moving Average
We now spend some time presenting two different estimation approaches. Firstly, we begin with the two-sided moving average approach.
Suppose there exist and an integer such that, near , the following approximation for the trend term holds (i.e., a two-sided moving average), assuming the underlying model is :
for all times in the interval . Note that the trend does not have to be a line globally, just to look linear on a small window of width around .
The estimate then averages the observations centered on and is given by:
If we substitute and split the sum, we get:
If we use the local linearity approximation, i.e., , we get:
We notice now that the offsets cancel, i.e., , so averaging preserves the trend's value at the center while averaging the noise.
The condition just says the whole window must fit within the observed data, from time to .
So we can conclude that:
That translates into saying that equals the true trend plus a small, averaged-out noise term.
Consider also that:
- Large averages out more noise, so the estimate is smoother, but the window should be small enough for the trend to be linear.
- Small , on the other hand, keeps the linearity assumption more plausible but leaves more noise (and this is the famous bias-variance trade-off!)
Furthermore, for a large , we can apply the Weak Law of Large Numbers (WLLN) to conclude that:
Intuition: for , as grows, the noise term is concentrated near .
Furthermore, for uncorrelated noise with variance , Chebyshev's inequality allows us to be more precise and state that:
We now spend some more time on the bias-variance trade-off. Let's start by considering:
Note that we assumed to be white noise, so it has mean , variance , and no correlation between samples. Also, note that is the linearization error (measuring how far the true trend is from the approximation line )
We now calculate the expectation of the estimator. The white-noise term vanishes because it has zero mean:
If we subtract and add the line , we have:
where the second equality holds since the average of the line equals , as shown before.
We now define the bias of the estimator as:
Intuition: the bias is the average linearization error over the window, minus the linearization error at the center. Therefore, if the trend is truly linear, both terms are and the estimator is unbiased.
On the other hand, if the trend is curved, the bias is non-zero, and it usually grows with (window size) because a wider window includes points where the line fits worse.
Furthermore, we can compute the mean squared error (MSE) using its standard decomposition:
Lastly, if we compute its variance, we immediately notice that, since is deterministic, it only comes from the noise, where, since the errors are uncorrelated, the variance "simply" adds up:
It is still interesting to point out that the plain average defined before is a special case of a broader family of estimators. Indeed, so far we used one specific way to average the window, equal weights, but this is not the only choice:
For example, we could put more weight near the center or more at the edges. In general, we can then say that:
where each condition can be written as follows:
- implies each constant trend passes through unchanged.
- implies a linear trend passes through unchanged.
Note also that any symmetric weights satisfy the second condition, and that is the simplest choice.
Parametric Estimation via Least Squares
We now spend some time with parametric estimation. Consider a model , where is noise, with the parametric assumption that the trend belongs to a finite-dimensional family of functions. That is, we can consider a polynomial of degree such that , where the unknowns are the coefficients.
For the least-squares estimator, we want to find the coefficients that make the curve as close as possible to the data under the squared-error sense, i.e., we want to find:
Intuition: is the total squared vertical distance between the data points and the polynomial, and note that we square it since we want a smooth, convex function. We therefore want to minimize it by finding the unique point where the slope in every direction is ; this means the least-squares estimator is a stationary point of .
We can then set , which gives the following linear system of equations in unknowns:
Intuition: the residuals are orthogonal to every regressor .
We can proceed with illustrative examples.
If (i.e., we have a constant trend), the equation is simply , which gives ; the best constant fit is the sample mean.
If (i.e., we have a linear trend), the two equations are:
If we divide by and do some algebra, we get:
Note that this is the simple-regression formula, with .
We now consider the matrix formula by stacking the data into and the coefficients into .
Let be the matrix whose row is , called the Vandermonde matrix.
Then the model becomes , which gives:
(The normal equation in matrix form) is , so , given that (i.e., we need at least as many data points as parameters, so that has full column rank and is invertible).
In this case, if the noise has zero mean, , i.e., the estimator is unbiased.
Furthermore, in the case of white noise, .
Estimating trend and seasonality together (nonparametric approach)
We now consider the following model:
where is the slowly moving trend, is a seasonal component with known period such that and sums to zero over one period, (without it, you could move a constant between and and get the same ).
Again, we assume that is locally linear.
The starting idea is that, to estimate the trend, we have to remove the seasonal component; averaging over exactly one full period does exactly this.
So, given that the seasonal period has length , we can set to be the half-width of the interval, so the simple equal-weight averaging works as follows:
We now focus on the case where is even (even if the opposite case can be solved similarly), so we can say:
(Note that this looks very similar to a moving average...)
Indeed, the weights and for satisfy
so we can use the same argument as before to show that .
Furthermore, the window covers exactly one period, and since they are steps apart, so the two half-weights add up to a single term and is the sum of over one full period, i.e., .
Lastly, using the WLLN, we can show that with high probability for large enough, so .
Remark that is large enough if and only if is large enough. Note also that we always take to be large enough because if is the smallest period of the seasonal component, then is also a period for .
Nonparametric estimation of the seasonal componentSuppose now that we know the trend exactly, so we can consider it as a “new observation” and consider:
Let be the largest integer such that . Then we have that:
where is unknown. So we can write:
To estimate , we then naturally use the empirical sample average, that is:
Instead, suppose now the trend is unknown, but we can replace it with for (since the two-sided window must fit inside the data). Then is the average deviation from the trend at seasonal position , defined as:
Then, in order to enforce the constraint , the final estimator is given by:
Intuition: the estimator averages across periods (to kill noise), subtracts the trend estimate (to isolate the season), and then re-centres the result (to fix the identifiability ambiguity between and ).
Parametric Estimation of the seasonal componentWe now introduce the parametric estimation of , with the assumption that the seasonal component follows a harmonic function, that is:
where , are known, and , and are unknown. To avoid trivialities, we assume that are not multiples of for all .
Furthermore, note that
To prove that, simply set , where is not a multiple of , so we have . Then , and we have that:
Note that in order to enforce the constraint , we must impose .
To estimate , we can use the least-squares approach based on the de-trended data , with . Then, the LSE estimator of is defined as:
Estimating by differencing
Suppose now the model is , with . We want to eliminate (the trend component) instead of estimating it, so we apply an operator that sends a polynomial trend into a constant (or to zero). In particular, we then define:
-
, the backward shift operator, which moves the series back by one step, defined as:
-
, the lag-1 differencing operator, which compares each value with the previous one (the discrete analogue of a derivative measuring the change per step), defined as:
where is the identity operator.
For , we can define recursively:
We can also show that:
Intuition: each application of lowers the degree by one, so after applications, a degree- polynomial is left as a coefficient, and only the leading coefficient survives, multiplied by (the same factor that appears when we differentiate times).
Note also that:
- Stationarity is preserved, i.e., if is stationary, then is a linear combination of shifted copies of and is therefore stationary too. The differenced series can therefore be managed with the usual stationary-friendly tools.
- Zero mean, i.e., since , we get , so can be estimated from the sample mean of the differenced series.
We also have the following properties:
- .
- If with , then .
- If and with , then .
- If is stationary, then is also stationary.