Time Series • Time Series Regression Model
Time Series / P5.01 Multivariate Time Series Idea

P5.01 Multivariate Time Series Idea

Practical 5 Time Series Regression Model

Store temperature, electricity demand and a weekday indicator as columns of one time-indexed table. Explain what makes the dataset multivariate rather than three separate unrelated files.

Practical / Solution

P5.01 Multivariate Time Series Idea

Problem Statement

Store temperature, electricity demand and a weekday indicator as columns of one time-indexed table. Explain what makes the dataset multivariate rather than three separate unrelated files.

Learning Outcomes

  • Define a multivariate series as several variables observed on the same times.
  • Align columns on one datetime index.
  • Give a reason they might move together.

Theory

A multivariate time series records two or more variables at the same dates. Joint structure can include contemporaneous correlation and lagged cross-effects. Analysing each column alone can miss those links. Alignment of timestamps is the first practical step.

Dataset / Data Source

Constructed 14 daily rows: temperature (°C), electricity demand (MWh), and a weekend flag. Teaching data for a small city-like example.

Analysis / Program

import pandas as pd idx = pd.date_range("2026-01-05", periods=14, freq="D") df = pd.DataFrame({ "temp_c": [18, 17, 16, 15, 21, 22, 19, 18, 17, 16, 20, 23, 22, 18], "demand_mwh": [31, 32, 33, 34, 28, 27, 30, 31, 33, 34, 29, 26, 27, 31], "is_weekend": [0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 1, 1, 0] }, index=idx) print(df) print("Shape:", df.shape) print("Columns:", list(df.columns)) print("Aligned index:", df.index.is_monotonic_increasing)

Expected Output

A 14 × 3 table with a daily index, shape (14, 3), and True for a sorted index. Demand is lower on the hotter weekend-like days in this construction.

Result / Interpretation

The three columns are one multivariate series because they share dates. Demand may fall when temperature rises or when it is weekend. Later practicals plot and model those links.

Note

Multivariate analysis starts with several series sharing the same time index.