Repository navigation
Update Posterior Dimension Lists For Multiple Posteriors - #342
Open
Sliderland wants to merge 6 commits into
Open
Sliderland wants to merge 6 commits into
Sliderland wants to merge 6 commits into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The dimensions field of a posterior is meant to give the number of unconstrained parameters for each variable in the Stan
parametersblock. The documentation vaguely states this but it isn't enforced in practice:hmm_gaussianusedA : [3, 2], now it's stored as6simplex[K]contributes K-1, sohmm_examplevariablestheta1/theta2change from 2 to 1.No reference draws were changed, and namely, the posterior dimension list shouldn't determine what variables are actually stored as reference draws. For example, in
eight_schools-eight_schools_noncentered, we are now storingtheta_transinstead oftheta(in the posterior dimensions list) despite the fact that the variable of interest istheta. This is due to the fact thattheta_transis the named variable that directly increases the unconstrained dimension, and notthetawhich is a derived variable. A couple of other posteriors were also affected in a similar way. Again, the reference draws have not been changed. I welcome any discussion about whether or not this is the correct approach for the posterior dimensions list.This PR was generated through my current implementation of the
posteriordb-rpackage. I will be updating that soon. The idea is that we compile the model through rstan and runrstan::get_num_upars, and then replace the list. My fork ofposteriordb-rdoes this under the hood when callingposteriordb::infer_posterior_dimensions. If you want to replicate this, run this file on posteriordbmasterbefore this PR. I would recommend a new branch/clean working tree. The file accepts cli arguments, so one could run it as follows:If you have cloned posteriordb into
~/posteriordb, the path to provide is~/posteriordb/posterior_databaseWithout --update, the script only writes a report to scripts/posterior_dimension_audit/, leaving posteriordb unchanged. If you use --no-output, you can skip the report. When using --update, the original JSON files are backed up before overwriting.
AI Disclosure: The script used to generate these changes started as my own hand-written loop over posteriors, but I used Codex to turn it into a standalone script that can be run from the terminal. I used claude to trace and reapply the commit, and to check that none of the remaining posteriors had shapes. Changes to my posteriordb-r fork were also AI-aided, but I will give a more detailed description in my future PRs to posteriordb-r