Repository navigation
Conversation
|
#907 made them blank in the console output rather than nan, which might be clearer to users (I worry an nan value would also trigger concerns) |
|
Why remove them? I've thought that before, but then realized reporting them makes sense because they're random variables. For example, reporting the mean and standard deviation of a random variable seems like MCSE on the mean would also make sense. Technically, these stats can be coupled into the Markov chain by conditional generation based on position and momentum each iteration. |
|
|
|
Thanks, @avehtari. If there's a natural place to add that last comment to the reference manual, that'd be very helpful to someone like me who will think through this just enough to be dangerous. |
|
I checked #907. Its description showed a sampler table without MCSE, ESS (then CmdStan 2.34.1, console: CmdStan 2.34.1, CSV: CmdStan 2.40.0, console: CmdStan 2.40.0, CSV: Both versions already print Would you prefer blank console cells for these rows? In the CSV file I would keep |
|
For parameters that have a different stationary distribution for each chain, you can still compute meaningful single-chain summaries and combine them as if they were the components of a mixture distribution. From that perspective, the full ESS is the sum of single-chain ESSes; R-hat and MCSE are root-mean-squares of the single-chain R-hats and MCSEs. |
It was rejected because in cases when the chain is constant due to being stuck by the failure of MCMC reporting ESS equal to the number of draws would be bad. At the point when we are computing ESS, we can't know whether the values are constant because 1) the quantity is truly structurally constant (ESS infinite make sense), 2) the chain is stuck because of failure (ESS 1 makes sense), or 3) a discretized quantity has low probability of visiting other discrete states and just hasn't yet visited them (e.g. when using indicator function x<=threshold, ESS not statistically well identified). Since we can't know at the point when we are computing which case holds, we decided to go with not available, and in R we would use NA, but as that is not available in Stan, we settled for nan.
I don't think that is relevant for our diagnostic quantities. For example, we would often prefer |
|
You write this PR "closes the remaining part of #903" but the reason those parts were left unclosed at the time is that Michael objected:
My reading of this is that even though different chains theoretically converge to different distributions, in practice detectable differences often indicate poor sampling. Though he also wrote:
so I guess he agrees that Rhat and ESS are best ignored here. "sum of single chain ESS" is not interesting unless multiple chains are partially stuck in which case it correctly signals the problem. In contrast,
Convergence is a global property. The important thing is that some diagnostic notices stuck chains; it doesn't matter much whether any individual ESS value looks problematic. The question should be whether a constant output is the only symptom of a stuck sampler. When a chain is not moving it could be because:
Okay, that last one is quite nasty and closely corresponds to a constant parameter. I'd still prefer a more specific diagnostic.
Both MCMC variance and true variance are zero. Any ESS is justifiable.
MCSE is calculated as
Any distribution, whether discrete or continuous, could have distant low probability modes that have not been visited yet. Such modes (if they exist) cause arbitrarily large bias in estimates of variance and ESS. That has never stopped us from estimating ESS; those estimates are just conditioned on the assumption of no unvisited modes. |
|
The current output has columns |
|
I'm OK with blank or "n/a", though either one seems like a rendering nightmare for a table. I also don't think we should hold up the PR for final fine tuning of columns. |
This PR was assisted by Claude
Submission Checklist
./runCmdStanTests.py src/test/interface/stansummary_test.cppSummary
This draft PR waits for the Stan submodule update that includes stan-dev/stan#3454. The first commit works with the current Stan submodule. The second commit updates test values that stan-dev/stan#3454 changes, so
stansummary_testfails with the current submodule until that update.Closes the remaining part of #903. MCSE, ESS, and R-hat are not meaningful for the sampler diagnostic columns
accept_stat__,stepsize__,treedepth__,n_leapfrog__,divergent__, andenergy__. #907 removed them in 2020; the currentget_stats()computes them again for all columns. Users who check that all R-hat values are close to 1 see values for these columns. For discrete columns such astreedepth__anddivergent__, the output is a number ornandepending on whether one split chain is constant.get_stats()has a new argumentconvergence_diagnostics(defaulttrue).stansummarysets it tofalsefor the sampler diagnostics. These rows then shownanfor MCSE, ESS_bulk, ESS_tail, ESS_bulk/s, and R_hat, in the console output and in the CSV file. Mean, StdDev, MAD, and the quantiles do not change.lp__keeps all columns.stan-dev/stan#3454 (fixes stan-dev/stan#3453) changes the ESS, R-hat, and MCSE functions that
stansummarycalls. Without this PR, the sampler rows would change with it, for exampletreedepth__would show an ESS where it now showsnan.Intended Effect
stansummary src/test/interface/example_output/bernoulli_chain_1.csv, sampler rows:How to Verify
./runCmdStanTests.py src/test/interface/stansummary_test.cpp. The expectedaccept_stat__andenergy__rows incheck_console_output,check_csv_output,check_csv_output_sig_figs, andcheck_csv_output_include_paramnow havenanin these columns.The second commit changes the expected MCSE of
lp__,theta,theta[6], andtheta[7]incheck_csv_output,check_csv_output_no_percentiles, andcheck_csv_output_include_paramto the values of stan-dev/stan#NNNN, which computesmcse_meanon split chains as the R packageposteriordoes.Results (Stan Math
579253050, g++ 14.3.0, Linux x86_64):developc3db9b995: 21 of 21 tests pass.fix-ess-constant-chainf324a5203: 21 of 21 tests pass.developsources with the test file of commit 1: 4 tests (5 expectations) fail,check_console_output,check_csv_output,check_csv_output_sig_figs, andcheck_csv_output_include_param.developsources with Stanfix-ess-constant-chain: 3 tests fail (check_csv_output,check_csv_output_no_percentiles,check_csv_output_include_param), because of the MCSE values that commit 2 updates.Side Effects
The CSV file from
--csv_filenamehasnanin these columns of the sampler rows. In the #907 discussion, CmdStanPy read this file forsummary(); an interface that reads it getsnanthere.Documentation
If the
stansummaryexamples in the CmdStan guide (stan-dev/docs) show values in these columns for the sampler rows, they need an update.Copyright and Licensing
Please list the copyright holder for the work you are submitting (this will be you or your assignee, such as a university or company):
Aalto University
By submitting this pull request, the copyright holder is agreeing to license the submitted work under the following licenses: