Household Energy Usage EDA

Part 2

Author

Santiago Rodriguez

Published

February 7, 2025

TLDR; Plots and practice from Forecasting Principles and Practice (Rob J Hyndman 2021).

About

Ch. 2 Time series graphics

Unhide
autoplot(tibble_energy, kwh) +
  labs(
    title = "Energy Usage",
    x = "Date"
  )

Unhide
tibble_energy |>
  subset(subset = date >= "2024-06-30" & date <= "2024-07-20") |>
  autoplot(kwh) +
    labs(
      title = "Energy Usage",
      subtitle = "July 2024",
      x = "Date"
    )+
  scale_x_date(date_breaks = "1 day", date_labels = "%a %b %d") +
  theme(axis.text.x = element_text(angle = 45, hjust = 1))

Patterns (ch. 2 page 37)

  • little or not trend
  • seasonality
    • annual
  • no apparent cycles

Seasonal plots

Unhide
tibble_energy |>
  fill_gaps() |>
  gg_season(kwh, period = "1y")+
  labs(
    title = "Sesaonal Plot",
    x = "Date"
  )+
  scale_x_date(
    date_breaks = "1 month",
    date_labels = "%b",  # Display months (Jan, Feb, etc.)
    sec.axis = sec_axis(
      trans = ~ .,  # Keeps the same scale
      name = "Quarter",
      labels = function(x) paste0("Q", ceiling(as.numeric(format(x, "%m")) / 3))
    )
  )

Unhide
tibble_energy |>
  fill_gaps() |>
  gg_season(kwh, period = "week")+
  labs(
    title = "Sesaonal Plot",
    x = "Date"
  )+
  theme(
    legend.position = "none"
  )

Unhide
tibble_energy |>
  fill_gaps() |>
  gg_season(kwh, period = "month")+
  labs(
    title = "Sesaonal Plot",
    x = "Date"
  )+
  theme(
    legend.position = "none"
  )

Takeaways

  • only obvious seasonal pattern is annual

Seasonal subseries plots

Plots illegible.

Scatterplots

Scatterplot matrices

Lag plots

Autocorrelation

Ch. 3 Time series decomposition

Rob J Hyndman, George Athanasopoulos. 2021. Forecasting Principles and Practice. Third. Otexts.