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_pathCoop
Coop - Example of hypothesis testing. See Chapter 4 in Regression and Other Stories.
Source: Coop/riverbay.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.
Data
riverbay = pd.read_csv(ros_path('Coop/data', 'Riverbay.csv'))
riverbay.head()| Othelia Jones | 208 | 416 | 867 | 1259 | 1610 | 2020 | Clotelia Smith | |
|---|---|---|---|---|---|---|---|---|
| 0 | Roger Toppin | 55 | 106 | 215 | 313 | 401 | 505 | Earl Coppin |
| 1 | Vanessa Fuentes | 133 | 250 | 505 | 716 | 902 | 1129 | Clarissa Montes |
| 2 | Gloria Wharton | 101 | 202 | 406 | 589 | 787 | 976 | NaN |
| 3 | Bernard Cylich | 108 | 249 | 512 | 745 | 970 | 1192 | NaN |
| 4 | Cecil McIntosh | 54 | 94 | 196 | 279 | 360 | 451 | NaN |
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.