Open damonbayer opened 3 weeks ago
After discussion with @dylanhmorris, we think it would be better for now to continue tracking deterministic random variables as we do now (or make them DeterministicVariable
s), but the models should be revised to actually track them.
So far, when we have wanted to track a "generated quantity" (a quantity which is not sampled directly, but is depends on quantities that are sampled), we have littered
numpyro.Deterministic
throughout the model code. This can be confusing because the name supplied innumpyro.Deterministic
may not correspond to the variable with that name in other parts of the code. E.g. there may be a numpyro site calledRt
but later in the model the variableRt
is padded. This paddedRt
will not be present in the posterior samples, even though it would be easier to use in post processing than the unpaddedRt
.Perhapes @dylanhmorris can fill us in if there is a more "correct" way to achieve this, but I propose adding a
generated_quantities
flag to the model arguments, collecting all of thenumpyro.Deterministic
random variables at the end of the model, and only callingnumpyro.Deterministic
ifgenerated_quantities = True
.Ex:
This ensures that the MCMC objects remain lean and useful for diagnostics, while allowing us to produce
generated_quantites
in a centralized location.