Time Series • Time Series Regression Model
Time Series / P5.02 Explore Related Series

P5.02 Explore Related Series

Practical 5 Time Series Regression Model

Using a longer constructed daily set of temperature, demand and a price-like series, inspect, clean if needed, plot each series, and examine pairwise relationships.

Practical / Solution

P5.02 Explore Related Series Together

Problem Statement

Using a longer constructed daily set of temperature, demand and a price-like series, inspect, clean if needed, plot each series, and examine pairwise relationships.

Learning Outcomes

  • Run a Kaggle-style inspection of several columns.
  • Visualise co-movement.
  • Compute correlations as a descriptive start.

Theory

Related series should be explored together before modelling. Correlation describes linear co-movement but is not causation and ignores lag structure. Overlaid plots with dual axes, or separate panels with a shared time axis, are clearer than dumping all units on one scale.

Dataset / Data Source

Constructed 60 daily observations: temperature, electricity demand, and a smoothed price-like index. Classroom data in the spirit of energy-demand studies, not a downloaded Kaggle file.

Kaggle-style Workflow

  • Import libraries
  • Load the aligned table
  • Inspect shape, dtypes, missing values
  • Descriptive statistics
  • Plot each series
  • Scatter or correlation view
  • Interpret co-movement

Analysis / Program

import numpy as np import pandas as pd import matplotlib.pyplot as plt rng = np.random.default_rng(11) idx = pd.date_range("2025-11-01", periods=60, freq="D") temp = 15 + 6 * np.sin(2 * np.pi * np.arange(60) / 7) + rng.normal(0, 0.8, 60) demand = 40 - 0.8 * temp + rng.normal(0, 1.2, 60) price = 50 + np.cumsum(rng.normal(0, 0.3, 60)) df = pd.DataFrame({"temp_c": temp, "demand_mwh": demand, "price_index": price}, index=idx) print("Shape:", df.shape) print(df.dtypes) print(df.isna().sum()) print(df.describe().round(2)) print("Correlation:\n", df.corr().round(2)) fig, axes = plt.subplots(3, 1, figsize=(8, 7), sharex=True) for ax, col in zip(axes, df.columns): df[col].plot(ax=ax, title=col) plt.tight_layout() plt.show()

Expected Output

Shape (60, 3), dtypes, a missing-value count of zeros, a describe table, a correlation matrix, and three aligned time plots. Temperature and demand should move in opposite directions in this construction.

Result / Interpretation

Joint EDA shows whether variables share peaks and troughs. Negative temp–demand correlation here matches a heating-like story. Price may wander more independently. Modelling comes after this picture.

Note

Plot related series on a shared time axis before fitting a multivariate model.