Skip to content

[ar1_bayes] Removed PyMC dependency and style-sheet compliance#569

Open
HumphreyYang wants to merge 12 commits into
mainfrom
update_ar1_bayes
Open

[ar1_bayes] Removed PyMC dependency and style-sheet compliance#569
HumphreyYang wants to merge 12 commits into
mainfrom
update_ar1_bayes

Conversation

@HumphreyYang

Copy link
Copy Markdown
Member

Key changes:

  • Removed PyMC: Removed all PyMC imports, installations, and model implementations
  • Updated variable naming: Used Greek letters (ρ, σ) instead of rho, sigma in NumPyro code
  • Code cleanup:
    • Cleaned up NumPyro implementation while preserving discussions
    • Fixed minor typos ("kernal" → "kernel")

@HumphreyYang HumphreyYang changed the title Removed PyMC dependency and style-sheet compliance [ar1_bayes] Removed PyMC dependency and style-sheet compliance Aug 22, 2025
@github-actions

github-actions Bot commented Aug 22, 2025

Copy link
Copy Markdown

@github-actions github-actions Bot temporarily deployed to pull request August 22, 2025 04:03 Inactive
@github-actions github-actions Bot temporarily deployed to pull request August 22, 2025 04:03 Inactive
@mmcky mmcky added the lecture label Aug 29, 2025
@HumphreyYang HumphreyYang marked this pull request as ready for review August 31, 2025 06:46
Comment thread lectures/ar1_bayes.md Outdated

@mmcky mmcky left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @HumphreyYang -- just one minor comment re: citation. Should I organise @thomassargent30 to review?

@mmcky mmcky requested a review from Copilot August 31, 2025 22:12

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR removes PyMC as a dependency from the AR(1) Bayesian analysis lecture, simplifying the codebase to use only NumPyro for Bayesian inference. The changes modernize variable naming conventions and clean up the implementation.

Key changes:

  • Removed all PyMC imports, installations, and model implementations
  • Updated variable naming to use Greek letters (ρ, σ) instead of Latin equivalents
  • Fixed minor typos and improved code consistency

Comment thread lectures/ar1_bayes.md
Comment thread lectures/ar1_bayes.md Outdated
Comment thread lectures/ar1_bayes.md Outdated
@mmcky mmcky added the review label Aug 31, 2025
HumphreyYang and others added 2 commits September 1, 2025 05:33
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Matt McKay <mmcky@users.noreply.github.com>
@github-actions github-actions Bot temporarily deployed to pull request September 1, 2025 22:09 Inactive
@github-actions github-actions Bot temporarily deployed to pull request September 1, 2025 22:09 Inactive
@HumphreyYang

Copy link
Copy Markdown
Member Author

Thanks @HumphreyYang -- just one minor comment re: citation. Should I organise @thomassargent30 to review?

Thanks Matt, I think it's fine. This is a minor change : )

@mmcky

mmcky commented Sep 3, 2025

Copy link
Copy Markdown
Contributor

thanks @HumphreyYang are you happy for me to merge this?

@mmcky mmcky requested a review from jstac September 5, 2025 01:29
@github-actions github-actions Bot temporarily deployed to pull request September 5, 2025 18:12 Inactive
@github-actions github-actions Bot temporarily deployed to pull request September 5, 2025 18:12 Inactive
@jstac

jstac commented Sep 7, 2025

Copy link
Copy Markdown
Contributor

@mmcky Where do I find the latest deployment?

I can see above "🚀 Deployed on https://68bb28185ee35015bb2cce79--nostalgic-wright-5fa355.netlify.app/"

I'm guessing this is out of date because it's not compliant with the syle manual (e.g., sentences running together instead of being followed by line breaks).

I find this PR a bit hard to jump into quickly because I'm unsure of the deployment and the title of the lecture is missing.

@github-actions github-actions Bot temporarily deployed to pull request September 7, 2025 07:52 Inactive
@github-actions github-actions Bot temporarily deployed to pull request September 7, 2025 07:52 Inactive
@HumphreyYang

HumphreyYang commented Sep 7, 2025

Copy link
Copy Markdown
Member Author

@mmcky Where do I find the latest deployment?

Many thanks @jstac, please see the latest deployment of the lecture Posterior Distributions for AR(1) Parameters:
https://68bd39bc9ca87aaef6818d45--nostalgic-wright-5fa355.netlify.app/ar1_bayes

We will include the lecture title and the latest deployment of the lecture next time we ping you for review.

Many thanks in advance!

(I pushed some more updates since I found some more paragraphs with multiple sentences)

@mmcky

mmcky commented Sep 8, 2025

Copy link
Copy Markdown
Contributor

@copilot I have attached our style-guide quantecon_review_instructions.md.

quantecon_review_instructions.md

Can you please review this lecture ar1_bayes and make sure it is style guide compliant.

Are you able to do a full review of this lecture and not just a review of the changes.

@HumphreyYang this sort of triggering doesn't work. I think it will only work when a PR is authored initially by copilot. I will do a full pass of this lecture on my local machine re: style compliance.

@HumphreyYang

Copy link
Copy Markdown
Member Author

Many thanks @mmcky, this PR should be compliant since I have run the same instruction on my end, but please let me know if your run spots anything new!

@mmcky

mmcky commented Sep 8, 2025

Copy link
Copy Markdown
Contributor

thanks @HumphreyYang -- you're right. I'll open an issue to figure out how we can improve the netlify deployment links. I find it interesting it doesn't post the latest one after each build.

@github-actions github-actions Bot temporarily deployed to pull request September 8, 2025 01:29 Inactive
@github-actions github-actions Bot temporarily deployed to pull request September 8, 2025 01:29 Inactive
@HumphreyYang

Copy link
Copy Markdown
Member Author

thanks @HumphreyYang -- you're right. I'll open an issue to figure out how we can improve the netlify deployment links. I find it interesting it doesn't post the latest one after each build.

Many thanks @mmcky! It's interesting that it posts deployment this time : )

@mmcky

mmcky commented Sep 9, 2025

Copy link
Copy Markdown
Contributor

@HumphreyYang it looks like netlify deployments disappear! Maybe that is part of the issue we are having.

@netlify

This comment was marked as outdated.

@github-actions

This comment was marked as outdated.

@github-actions github-actions Bot temporarily deployed to pull request September 9, 2025 03:59 Inactive
@github-actions github-actions Bot temporarily deployed to pull request September 10, 2025 01:48 Inactive
@github-actions

Copy link
Copy Markdown

📖 Netlify Preview Ready!

Preview URL: https://pr-569--sunny-cactus-210e3e.netlify.app (7e829d7)

📚 Changed Lecture Pages: ar1_bayes

@github-actions

Copy link
Copy Markdown

📖 Netlify Preview Ready!

Preview URL: https://pr-569--sunny-cactus-210e3e.netlify.app (075b0bb)

📚 Changed Lecture Pages: ar1_bayes

Comment thread lectures/ar1_bayes.md
@github-actions

Copy link
Copy Markdown

📖 Netlify Preview Ready!

Preview URL: https://pr-569--sunny-cactus-210e3e.netlify.app (255d027)

📚 Changed Lecture Pages: ar1_bayes

@jstac

jstac commented Sep 19, 2025

Copy link
Copy Markdown
Contributor

I find this code quite confusing:

def AR1_model(data):
    # Set prior
    ρ = numpyro.sample('ρ', dist.Uniform(low=-1., high=1.))
    σ = numpyro.sample('σ', dist.HalfNormal(scale=jnp.sqrt(10)))

    # Expected value of y in the next period (ρ * y)
    yhat = ρ * data[:-1]

    # Likelihood of the actual realization
    numpyro.sample('y_obs', 
                dist.Normal(loc=yhat, scale=σ), obs=data[1:])

I think I've gotten used to JAX's functional style... Nothing is being returned here. How does it work?

Maybe I'm the only one who finds this confusing. Or maybe we need some discussion around the code to explain how it works...

@HumphreyYang

HumphreyYang commented Sep 20, 2025

Copy link
Copy Markdown
Member Author

I think I've gotten used to JAX's functional style... Nothing is being returned here. How does it work?

Hi @jstac, I think that concern is totally fair. I was confused when I first saw this syntax. NumPyro uses a functional core with an imperative shell: the function here is just a specification (like writing specification down in sympy), and a stack of effect handlers (dynamic, thread-local) reinterprets each numpyro.sample(...) during execution.

When we call mcmc.run(...), the kernel (e.g., NUTS) builds a pure log-density from the model via these handlers and then does the sampling. So the handlers don’t do sampling per sa; they construct the potential function the sampler needs.

It can be a bit much for readers who just want posterior draws, so I can add a few simple notes next to the first NumPyro code cells in the previous lecture to demystify this a little.

If that sounds good, I’ll open a separate issue and PR.

@jstac

jstac commented Sep 20, 2025

Copy link
Copy Markdown
Contributor

Thanks @HumphreyYang , that would be great.

I'm starting to really appreciate the explicitness and clean logic of JAX.

@jstac

jstac commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

🤖 Status note for a future session — from a maintainer investigation on 2026-07-08 into why open-PR previews 404. Context only, not instructions.

Netlify preview: https://pr-569--sunny-cactus-210e3e.netlify.app/ currently returns 404.

Why previews are down (repo-wide findings)

1. This branch is stale — 181 commits behind main. A preview build compiles the whole site from this branch. This branch's lectures/house_auction.md still has unpinned !pip install prettytable, which now breaks on a wcwidth incompatibility. main fixed this on 2026-06-28 by pinning prettytable<3.18 (#939). This alone fails any rebuild of this branch until it's updated to main.

2. The arviz failure was a red herring — do NOT pin arviz or rewrite plotting. A 2026-07-07 rebuild also failed in ar1_bayes/ar1_turningpts with an arviz_plots figsize ValueError. That was a transient bug in an intermediate arviz-plots 1.x release, already fixed in arviz 1.2.0. Verified locally on a clean latest-stack venv: the real az.plot_trace(trace) cell (pymc + numpyro InferenceData) runs green. The lectures use only 1.x-compatible arviz APIs (plot_trace, summary, from_numpyro, compare).

⭐ Directly relevant to this PR

This PR edits ar1_bayes.md — one of the two lectures that tripped the arviz-plots figsize bug. It is already fixed upstream in arviz 1.2.0 (verified: az.plot_trace on a real pymc AR1 posterior renders on the latest stack). So there is nothing to fix in the arviz code here — focus on updating the branch to main and rebuilding.

Recommended first step for this PR

Update this branch to main (merge or rebase — pulls in #939 plus ~181 other commits), then let CI rebuild. On today's latest libraries the site builds clean, so the preview should return. house_auction is the known blocker; updating also picks up other since-merged fixes — rebuild and address any remaining per-lecture failures. Verify with:

curl -sI https://pr-569--sunny-cactus-210e3e.netlify.app/ar1_bayes.html

This PR touches: ar1_bayes.md. Last CI build: success@2025-09-19. Branch: 181 commits behind main as of 2026-07-08.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants