Skip to content

[unemployment_shocks] Rigorous LOO derivation + jax-only computation#941

Merged
jstac merged 2 commits into
mainfrom
asym_edits
Jun 30, 2026
Merged

[unemployment_shocks] Rigorous LOO derivation + jax-only computation#941
jstac merged 2 commits into
mainfrom
asym_edits

Conversation

@jstac

@jstac jstac commented Jun 30, 2026

Copy link
Copy Markdown
Contributor

Tightens the Comparing models with cross-validation → Computational methods section of unemployment_shocks, in response to a review that the importance-sampling argument was too heuristic for an advanced-analysis audience.

What changed

Prose. The derivation of the leave-one-out predictive density is rewritten as a formal assumption / proposition / proof (using sphinx_proof):

  • The conditional-independence assumption is stated up front — and plainly flagged as false for the autoregression, adopted for tractability, with consequences deferred to the time-series-structure section.
  • The proof is a clean chain of equalities establishing the exact Gelfand identity
    $$\tfrac{1}{p(u_i\mid u_{-i})} = \int \tfrac{1}{p(u_i\mid\theta)},p(\theta\mid u),d\theta,$$
    with explicit integral notation (no E[·]) so the integrating density is visible at every step.
  • The harmonic-mean estimator then follows as an ordinary Monte Carlo average; since the integrand has finite mean, the law of large numbers makes the approximation exact with probability one as $S\to\infty$, while a possibly-infinite variance motivates the PSIS refinement that follows.
  • Blank-line-per-sentence convention applied throughout.

Code. The pointwise LOO computation now stays entirely in jax (jax.scipy.special.logsumexp, jnp.log, jnp.sqrt) instead of round-tripping through numpy/scipy.

COVID remains excluded: at annual end-of-year frequency the episode is a single 6.7% point with a V-shaped (fast-up-fast-down) recovery, which cuts against the asymmetry thesis rather than illustrating it.

Testing

Ran end-to-end on GPU (jupytext --to py):

  • r_hat = 1.00, 0 divergences
  • elpd difference 11.8 vs SE 5.7 (~2 SEs)
  • effective parameters p = 3.6 (linear), 6.5 (jump)
  • all Pareto $\hat k$ < 0.7; jump model ranked first by az.compare
  • observed skewness 0.77, inside the posterior-predictive bulk

All numerical claims in the prose match the run.

🤖 Generated with Claude Code

Rewrite the "Computational methods" section as a formal
assumption/proposition/proof: state the conditional-independence
assumption (noting it is false for the time series and revisited
below), prove the exact Gelfand identity for the LOO predictive
density, and obtain the harmonic-mean estimator as a Monte Carlo
average that becomes exact a.s. as S -> infinity. Use explicit
integral notation throughout and follow the blank-line-per-sentence
convention.

Keep the pointwise LOO computation entirely in jax
(jax.scipy.special.logsumexp, jnp.log, jnp.sqrt) instead of bouncing
between jax and numpy.

Verified end-to-end on GPU: r_hat=1.00, 0 divergences, elpd diff 11.8
vs SE 5.7, p_loo 3.6/6.5, all Pareto k < 0.7.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@github-actions

github-actions Bot commented Jun 30, 2026

Copy link
Copy Markdown

📖 Netlify Preview Ready!

Preview URL: https://pr-941--sunny-cactus-210e3e.netlify.app

Commit: e844b40

📚 Changed Lectures


Build Info

Trim the LOO exposition: drop the infinite-variance/importance-weights
caveat and the Pareto-k/PSIS and AIC/BIC discussion (kept consistent,
no dangling references). Remove the posterior-predictive asymmetry
section, and adjust the plan and conclusion so the lecture no longer
promises a check it no longer performs. Fix a few typos.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@jstac jstac merged commit 68e893d into main Jun 30, 2026
1 check passed
@jstac jstac deleted the asym_edits branch June 30, 2026 21:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant