Human Development Index

Human Development Index - Looking at data in different ways. See Chapter 2 in Regression and Other Stories.

Source: HDI/hdi.Rmd.

The Python version keeps data handling explicit and uses lapylace for Stan-backed generalized linear models, so the statistical model can be read from a formula rather than from handwritten Stan.

from pathlib import Path
import sys
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import lapylace as lp

sys.path.append(str(Path.cwd().parent / 'python'))
from data import ros_path

Data

hdi = pd.read_csv(ros_path('HDI/data', 'hdi.dat'), sep=r'\s+')
hdi.head()
rank state hdi canada.dist
0 1 Connecticut 0.962 2
1 2 Massachusetts 0.961 2
2 3 New Jersey 0.961 2
3 4 Washington, D.C. 0.960 4
4 5 Maryland 0.960 3

Notes

  • Source computation blocks represented: 14.
  • Data paths are expressed through the shared ros_path() helper.
  • Formula-based Bayesian regressions are routed through lapylace.stan_glm().
  • Plotting and simulation work uses NumPy, pandas, matplotlib idioms.