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

Course Content

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

bookConvert 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):

Task
test

Swipe to show code editor

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.

Switch to desktopSwitch to desktop for real-world practiceContinue from where you are using one of the options below
Everything was clear?

How can we improve it?

Thanks for your feedback!

Section 5. Chapter 2
toggle bottom row

bookConvert 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):

Task
test

Swipe to show code editor

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.

Switch to desktopSwitch to desktop for real-world practiceContinue from where you are using one of the options below
Everything was clear?

How can we improve it?

Thanks for your feedback!

Section 5. Chapter 2
toggle bottom row

bookConvert 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):

Task
test

Swipe to show code editor

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.

Switch to desktopSwitch to desktop for real-world practiceContinue from where you are using one of the options below
Everything was clear?

How can we improve it?

Thanks for your feedback!

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):

Task
test

Swipe to show code editor

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.

Switch to desktopSwitch to desktop for real-world practiceContinue from where you are using one of the options below
Section 5. Chapter 2
Switch to desktopSwitch to desktop for real-world practiceContinue from where you are using one of the options below
We're sorry to hear that something went wrong. What happened?
some-alt