Storable

Ordered categorical data analysis with a study from experimental economics, on the topic of ``storable votes’’. See Chapter 15 in Regression and Other Stories.

Source: Storable/storable.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

games_2player = pd.read_csv(ros_path('Storable/data', '2playergames.csv'))
games_2player.head()

games_3player = pd.read_csv(ros_path('Storable/data', '3playergames.csv'))
games_3player.head()

games_6player = pd.read_csv(ros_path('Storable/data', '6playergames.csv'))
games_6player.head()
school person round proposal value vote cutoff.12 cutoff.23 sd.logit
0 1 101 1 1 16 1 32.835 58.75 1.103
1 1 101 2 1 23 1 32.835 58.75 1.103
2 1 101 3 1 63 3 32.835 58.75 1.103
3 1 101 4 1 98 3 32.835 58.75 1.103
4 1 101 5 1 16 1 32.835 58.75 1.103

Notes

  • Source computation blocks represented: 7.
  • 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.