Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Apprendre Convert Non-Stationary Data to Stationary | Non-Stationary Models
Time Series Analysis
course content

Contenu du cours

Time Series Analysis

Time Series Analysis

1. Time Series: Let's Start
2. Time Series Processing
3. Time Series Visualization
4. Stationary Models
5. Non-Stationary Models
6. Solve Real Problems

book
Convert Non-Stationary Data to Stationary

So, let's move on to the stage of processing non-stationary data. You have already seen predictive models that you can use to work with stationary data, but since most data is non-stationary, there are ways to convert it.

There are many types of transformations, such as difference, logarithmic transformation, proportional change, etc. But the main idea of mathematical transformations is to apply some function for each value of the time series to remove the time dependence (this includes trends and seasonality).

We will start with the differencing used in the ARIMA model. The principle is simple - the past value is subtracted from the current one:

This allows you to stabilize the value of the time series, making it more constant. Let's implement the difference transformation using Python:

Let's move on to the logarithmic transformation. If the difference allows us to equalize the mean, then the logarithmic transformation stabilizes the time series variance. The only limitation is that the logarithmic transformation can only work with positive values.

Below is the code for logarithmic transformation (log transformation):

Tâche

Swipe to start coding

Implement a difference transformation on the AirPassengers.csv dataset and output the average before and after for the #Passengers column.

  1. Read the AirPassengers.csv file.
  2. Drop the "Month" column out of the df DataFrame.
  3. Calculate the mean value of the "#Passengers" column before changes.
  4. Calculate the differences of each value of the column"#Passengers" compared with the previous (periods = 1`), drop NA values, and calculate the mean for the updated column.

Solution

Switch to desktopPassez à un bureau pour une pratique réelleContinuez d'où vous êtes en utilisant l'une des options ci-dessous
Tout était clair ?

Comment pouvons-nous l'améliorer ?

Merci pour vos commentaires !

Section 5. Chapitre 2
toggle bottom row

book
Convert Non-Stationary Data to Stationary

So, let's move on to the stage of processing non-stationary data. You have already seen predictive models that you can use to work with stationary data, but since most data is non-stationary, there are ways to convert it.

There are many types of transformations, such as difference, logarithmic transformation, proportional change, etc. But the main idea of mathematical transformations is to apply some function for each value of the time series to remove the time dependence (this includes trends and seasonality).

We will start with the differencing used in the ARIMA model. The principle is simple - the past value is subtracted from the current one:

This allows you to stabilize the value of the time series, making it more constant. Let's implement the difference transformation using Python:

Let's move on to the logarithmic transformation. If the difference allows us to equalize the mean, then the logarithmic transformation stabilizes the time series variance. The only limitation is that the logarithmic transformation can only work with positive values.

Below is the code for logarithmic transformation (log transformation):

Tâche

Swipe to start coding

Implement a difference transformation on the AirPassengers.csv dataset and output the average before and after for the #Passengers column.

  1. Read the AirPassengers.csv file.
  2. Drop the "Month" column out of the df DataFrame.
  3. Calculate the mean value of the "#Passengers" column before changes.
  4. Calculate the differences of each value of the column"#Passengers" compared with the previous (periods = 1`), drop NA values, and calculate the mean for the updated column.

Solution

Switch to desktopPassez à un bureau pour une pratique réelleContinuez d'où vous êtes en utilisant l'une des options ci-dessous
Tout était clair ?

Comment pouvons-nous l'améliorer ?

Merci pour vos commentaires !

Section 5. Chapitre 2
Switch to desktopPassez à un bureau pour une pratique réelleContinuez d'où vous êtes en utilisant l'une des options ci-dessous
We're sorry to hear that something went wrong. What happened?
some-alt