Time Series • Time Series Analysis and Components
Time Series / P2.07 Logarithmic Transformation

P2.07 Logarithmic Transformation

Practical 2 Time Series Analysis and Components

A positive series grows with increasing variation. Compare the original plot with a log plot and explain when a log is helpful.

Practical / Solution

P2.07 Logarithmic Transformation

Problem Statement

A positive series grows with increasing variation. Compare the original plot with a log plot and explain when a log is helpful.

Learning Outcomes

  • Apply a log transform to positive data.
  • Explain that logs can stabilise relative growth.

Hint

Use np.log on strictly positive values. Do not log zeros or negatives.

Theory

Transformations can stabilise variance or make growth more linear. A logarithm turns multiplicative growth into additive growth. It is not always required.

Dataset / Data Source

Constructed positive series: 20, 24, 30, 38, 50, 66, 90, 125.

Analysis / Program

import pandas as pd import numpy as np import matplotlib.pyplot as plt y = pd.Series([20, 24, 30, 38, 50, 66, 90, 125]) fig, axes = plt.subplots(1, 2, figsize=(9, 4)) y.plot(ax=axes[0], marker="o", title="Original") np.log(y).plot(ax=axes[1], marker="o", title="Log") plt.tight_layout() plt.show()

Expected Output

Two plots: original curve steepening upward, log series closer to a straight rise.

Result / Interpretation

If variation grows with the level, a log scale can make the pattern easier to model. Forecasts on the log scale must be converted back carefully.

Note

Use a log only for positive data, and interpret results on the original scale when the decision uses original units.