You can transform time series to:

Isolate temporal components of interest.

Remove the effect of nuisance components (like seasonality).

Make a series stationary.

Reduce spurious regression effects.

Stabilize variability that grows with the level of the series.

Make two or more time series more directly comparable.

You can choose among many data transformation to address these (and other) aims.

For example, you can use decomposition methods to describe and estimate time series components. Seasonal adjustment is a decomposition method you can use to remove a nuisance seasonal component.

Detrending and differencing are transformations you can use to address nonstationarity due to a trending mean. Differencing can also help remove spurious regression effects due to cointegration.

In general, if you apply a data transformation before modeling
your data, you then need to back-transform model forecasts to return
to the original scale. This is not necessary in Econometrics
Toolbox™ if
you are modeling difference-stationary data. Use `arima`

to
model integrated series that are not *a priori* differenced.
A key advantage of this is that `arima`

also returns
forecasts on the original scale automatically.

Some nonstationary series can be modeled as the sum of a deterministic
trend and a stationary stochastic process. That is, you can write
the series *y _{t}* as

$${y}_{t}={\mu}_{t}+{\epsilon}_{t},$$

where $${\epsilon}_{t}$$ is a stationary stochastic process with mean zero.

The deterministic trend, *μ _{t}*,
can have multiple components, such as nonseasonal and seasonal components.
You can detrend (or decompose) the data to identify and estimate its
various components. The detrending process proceeds as follows:

Estimate the deterministic trend component.

Remove the trend from the original data.

(Optional) Model the remaining residual series with an appropriate stationary stochastic process.

Several techniques are available for estimating the trend component. You can estimate it parametrically using least squares, nonparametrically using filters (moving averages), or a combination of both.

Detrending yields estimates of all trend and stochastic components, which might be desirable. However, estimating trend components can require making additional assumptions, performing extra steps, and estimating additional parameters.

Differencing is an alternative transformation for removing a
mean trend from a nonstationary series. This approach is advocated
in the Box-Jenkins approach to model specification [1]. According to this methodology,
the first step to build models is differencing your data until it
looks stationary. Differencing is appropriate for removing *stochastic* trends
(e.g., random walks).

Define the first difference as

$$\Delta {y}_{t}={y}_{t}-{y}_{t-1},$$

where Δ is called
the *differencing operator*. In lag operator notation,
where $${L}^{i}{y}_{t}={y}_{t-i},$$

$$\Delta {y}_{t}=(1-L){y}_{t}.$$

You can create lag
operator polynomial objects using `LagOp`

.

Similarly, define the second difference as

$${\Delta}^{2}{y}_{t}={(1-L)}^{2}{y}_{t}=({y}_{t}-{y}_{t-1})-({y}_{t-1}-{y}_{t-2})={y}_{t}-2{y}_{t-1}+{y}_{t-2}.$$

Like taking derivatives, taking a first difference makes a linear
trend constant, taking a second difference makes a quadratic trend
constant, and so on for higher-degree polynomials. Many complex stochastic
trends can also be eliminated by taking relatively low-order differences.
Taking *D* differences makes a process with *D* unit
roots stationary.

For series with seasonal periodicity, *seasonal* differencing
can address seasonal unit roots. For data with periodicity *s* (e.g.,
quarterly data have *s* = 4 and monthly data have *s* =
12), the seasonal differencing operator is defined as

$${\Delta}_{s}{y}_{t}=(1-{L}^{s}){y}_{t}={y}_{t}-{y}_{t-s}.$$

Using a differencing transformation eliminates the intermediate estimation steps required for detrending. However, this means you can’t obtain separate estimates of the trend and stochastic components.

For a series with exponential growth and variance that grows with the level of the series, a log transformation can help linearize and stabilize the series. If you have negative values in your time series, you should add a constant large enough to make all observations greater than zero before taking the log transformation.

In some application areas, working with differenced, logged series is the norm. For example, the first differences of a logged time series,

$$\Delta \mathrm{log}{y}_{t}=\mathrm{log}{y}_{t}-\mathrm{log}{y}_{t-1},$$

are approximately the *rates of change* of
the series.

The rates of change of a price series are called *returns*.
Whereas price series do not typically fluctuate around a constant
level, the returns series often looks stationary. Thus, returns series
are typically used instead of price series in many applications.

Denote successive price observations made at times *t* and *t* +
1 as *y*_{t} and *y*_{t+1},
respectively. The *continuously compounded returns series* is
the transformed series

$${r}_{t}=\mathrm{log}\frac{{y}_{t+1}}{{y}_{t}}=\mathrm{log}{y}_{t+1}-\mathrm{log}{y}_{t}.$$

This is the first difference of the log price series, and is
sometimes called the *log return*.

An alternative transformation for price series is *simple
returns*,

$${r}_{t}=\frac{{y}_{t+1}-{y}_{t}}{{y}_{t}}=\frac{{y}_{t+1}}{{y}_{t}}-1.$$

For series with relatively high frequency (e.g., daily or weekly
observations), the difference between the two transformations is small. Econometrics
Toolbox has `price2ret`

for
converting price series to returns series (with either continuous
or simple compounding), and `ret2price`

for the inverse
operation.

[1] Box, G. E. P., G. M. Jenkins, and G. C.
Reinsel. *Time Series Analysis: Forecasting and Control*.
3rd ed. Englewood Cliffs, NJ: Prentice Hall, 1994.

- Transform Time Series Using Econometric Modeler App
- Moving Average Trend Estimation
- Nonseasonal Differencing
- Nonseasonal and Seasonal Differencing
- Parametric Trend Estimation
- Specify Lag Operator Polynomials