Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

This notebook performs Leave-One-Out (LOO) analysis and data attribution for the hierarchical selection bias model. It identifies which score bins have the greatest influence on the model’s predictions.

Load Saved InferenceData

Load the saved InferenceData from the hierarchical model. This allows us to perform LOO analysis without re-running the model. If the file isn’t here, the next cell downloads it (about 180 MB) from the fit-2026-11 release, a refit of selection_bias3.ipynb that matches the published results and includes the pointwise log-likelihood.

Available log-likelihood groups: ['obs_bins']
obs_bins log-likelihood shape: (4, 1000, 5, 2)

Load Data for Visualization

We need the original data and score bins for plotting.

Counts array shape: (5, 2, 61)

Compute Influence

The influence computation uses PSIS-LOO to identify which observations (score bins) have the greatest impact on the model’s predictions.

Available posterior variables: ['mu', 'sigma', 'beta', 'sigma_noise', 'log_noise_raw', 'log_noise', 'pdf', 'p_take', 'test_pdf']
/home/downey/miniconda3/envs/SelectionSAT/lib/python3.13/site-packages/arviz/stats/stats.py:797: UserWarning: Estimated shape parameter of Pareto distribution is greater than 0.70 for one or more samples. You should consider using a more robust model, this is because importance sampling is less likely to work well if the marginal posterior and LOO posterior are very different. This is more likely to happen with a non-robust model and highly influential observations.
  warnings.warn(
Influence shape: (5, 2, 61)
Pareto-k shape: (5, 2, 61)
Problematic observations (Pareto-k > 0.7): 610 out of 610 (100.0%)

Visualize Influence

Create a faceted plot showing the observed score distributions with influence scores overlaid as semi-transparent circles.

Influence shape: (5, 2, 61)
Years: [2011, 2012, 2013, 2014, 2015]
Sexes: ['Male', 'Female']
First year, Male (index 0,0) sum: -2971569.1653791643
First year, Female (index 0,1) sum: -3341924.001840362
<Figure size 1350x450 with 10 Axes>

Summary Statistics

Loading...
Top 10 most influential observations:
  2011 Female Score 460: influence=-123109.637, Pareto-k=5.750
  2015 Female Score 470: influence=-121418.253, Pareto-k=6.245
  2014 Female Score 470: influence=-119193.197, Pareto-k=6.973
  2011 Female Score 490: influence=-118810.895, Pareto-k=5.750
  2012 Female Score 470: influence=-118521.423, Pareto-k=6.692
  2014 Female Score 500: influence=-117268.206, Pareto-k=6.973
  2013 Female Score 480: influence=-117149.876, Pareto-k=6.846
  2013 Female Score 510: influence=-116241.707, Pareto-k=6.846
  2012 Female Score 500: influence=-115484.776, Pareto-k=6.692
  2012 Female Score 440: influence=-114745.910, Pareto-k=6.692

Interpretation

The influence scores show which score bins have the greatest impact on the model’s predictions. High influence values indicate that removing that particular score bin would substantially change the model’s predictions.

Pareto-k values indicate the reliability of the LOO approximation:

  • Pareto-k < 0.5: Good approximation

  • 0.5 ≤ Pareto-k < 0.7: OK approximation, but some caution needed

  • Pareto-k ≥ 0.7: Problematic - the LOO approximation may be unreliable for these observations

The visualization uses:

  • Marker size: Proportional to absolute influence score

  • Marker color: Red for high Pareto-k (> 0.7), orange for medium (0.5-0.7), blue for low (< 0.5)

  • Marker transparency: Higher opacity for more problematic observations

SelectionSAT

Copyright 2025 Allen Downey

Code license: MIT License

Text license: CC BY-NC-SA 4.0