Many advertising measures can often be considered as time series data:
- Impressions over time
- Click-through rate (CTR)
- Ad spend over time
- Conversion rates over time
What is a Time Series?
A sequence of data points collected over time .
-
Time series analysis to find the below:
where:
- : Trend component (long-term movement)
- : Seasonal component (regular patterns)
- : Irregular component (stationary noise at time )
- : Cyclical component (long-term cycles) - not shown
-
Time series forecasting:
Characteristics of Time Series Data
-
Stochastic Process: A collection of random variables indexed by time.
-
Dependency: There is dependency between random variables at different time points.
- Hence, we need to consider joint distributions, not only marginal distributions.
- Auto-covariance and auto-correlation functions are used to measure this dependency.
-
Stationarity: A time series is stationary if its statistical properties (mean, variance, autocovariance) do not change over time.
- For non-stationary series, we can often transform them to stationary series using differencing, detrending, nonlinear transformations, etc.
Note
Strict Stationarity
A time series is said to be strictly stationary if the joint distribution of is the same as that of for all and all . The joint distribution of is invariant under time shift. This is a strong condition; rarely encountered in practice.
Weak Stationarity
A time series is said to be weakly stationary if its mean and variance are constant over time, and the covariance between and depends only on the lag and not on the actual time .
In practice, weak stationarity is a more common assumption than strict stationarity, as many time series exhibit constant mean and variance but may not have identical joint distributions under time shifts.
Mathematical Properties
Lag-l autocovariance of
where:
- : lag-l autocovariance
- : variance of
- : symmetry property
Lag-l autocorrelation of
Where the property of for a weakly stationary process.
High autocorrelation at lag indicates a strong linear relationship between and , meaning past values have a significant influence on current values.
In general the autocorrelation of is defined as:
where and is the sample mean of .
Examples of Time Series Models
Choose model based on the characteristics of the time series data.
- Autoregressive (AR) model
- Moving Average (MA) model
- Integrated (I) model
- ARMA model
- ARIMA model
- Seasonal ARIMA (SARIMA) model
- Fractional ARIMA (FARIMA) model
Autoregressive (AR) Model
An AR model expresses predicts the variable as a linear regression of the past values of the variable.
For AR model of order (AR(p)):
where is the best estimate of given past values, and are the model parameters to be estimated from the data.
- Error:
- Model: (for AR(1))
- Minimize the sum of squared errors (SSE):
Assumptions
- Linearity: The relationship between the current value and past values is linear.
- Normal independent and identically distributed (i.i.d.) errors: The error terms are normally distributed with mean zero and constant variance. (i.e. no autocorrelation)
- Additive errors: The error terms are added to the linear combination of past values.
- Stationarity: The time series is stationary, meaning its statistical properties do not change over time. ---> most important assumption!!
Backward Shift Operator
The backward shift operator is defined as:
then the AR(p) model can be written as:
where is the characteristic polynomial of the AR(p) model.
How to estimate coefficients
Estimated by minimizing the sum of squared errors (SSE) using multiple linear regression.
Minimize SSE to find the optimal coefficients . This is a multiple linear regression problem.
Determining the order of the AR model
By using the partial autocorrelation function (PACF).
Note
PACF is the autocorrelation between and after removing the effects of the intermediate lags . It is the conditional correlation between and given the values of .
Example:
The first order partial autocorrelation will defined to equal the first order autocorrelation.
The second order (lag) partial autocorrelation is:
where and are the linear regression estimates of and on and respectively.
The third order (lag) partial autocorrelation is:
where and are the linear regression estimates of and on and respectively.
Moving Average (MA) Model
An MA model expresses the variable as a linear combination of past error terms.
For MA model of order (MA(q)):
For order 1 (MA(1)):
MA(0) = AR(0) = white noise = =
Where, is the mean of the time series.
Backward shift operator B
Using the backward shift operator , the MA(q) model can be written as:
Autocorrelation
For MA(1):
The autocorrelation of MA(q) is non-zero only for lags up to .
Determining the order of the MA model
The order of the last significant autocorrelation determines the order of the MA model.
Integrated (I) Model
Used for non-stationary time series data to make it stationary by differencing.
White noise: , but the mean is independent of time.
If the time series is parabolic, the second difference can be modeled as white noise (I(2)):
Two levels of differencing.
ARMA and ARIMA Models
It is possible to combine AR, MA, and I components into a single model.
ARMA(p, q) Model
Combines AR(p) and MA(q) models for stationary time series:
Where:
- (AR part)
- (MA part)
ARIMA(p, d, q) Model
For non-stationary time series, we can use differencing to make it stationary and then apply ARMA:
Where:
- : order of differencing