In a run of a model I just did overnight, all four chains ran, each giving a final statement along the lines of:

Chain 4: Iteration: 2000 / 2000 [100%] (Sampling)

Chain 4:

Chain 4: Elapsed Time: 26026 seconds (Warm-up)

Chain 4: 25768.7 seconds (Sampling)

Chain 4: 51794.6 seconds (Total)

Chain 4:

but two of them didn’t give me any samples:

[[1]]

Stan model ‘Area_and_Hunt_Trend2’ does not contain samples.[[2]]

Stan model ‘Area_and_Hunt_Trend2’ does not contain samples.

All chains have some issues, most commonly things like

Chain 3: Exception: neg_binomial_2_rng: Location parameter is 0, but must be > 0! (in ‘model109862dc13082_Area_and_Hunt_Trend2’ at line 917)

Chain 3: Exception: neg_binomial_2_rng: Location parameter is inf, but must be finite! (in ‘model109862dc13082_Area_and_Hunt_Trend2’ at line 917)

Chain 1: Exception: neg_binomial_2_rng: Random number that came from gamma distribution is 1.17979e+11, but must be less than 1.07374e+09 (in ‘model109862dc13082_Area_and_Hunt_Trend2’ at line 917)

where line 917 generates samples, and the issue here is numerical problems with either very small or very large location parameters. I don’t think these are the issues causing problems since they occur in all chains, but two also have these issues:

[126] “Chain 1: Informational Message: The current Metropolis proposal is about to be rejected because of the following issue:”

[127] “Chain 1: Exception: validate transformed params: beta[i_0__][i_1__] is -nan, but must be greater than or equal to 0 (in ‘model109862dc13082_Area_and_Hunt_Trend2’ at line 157)”

[128] “Chain 1: If this warning occurs sporadically, such as for highly constrained variable types like covariance matrices, then the sampler is fine,”

[129] “Chain 1: but if this warning occurs often then your model may be either severely ill-conditioned or misspecified.”

[130] "Chain 1: "

[131] “Chain 1: Informational Message: The current Metropolis proposal is about to be rejected because of the following issue:”

[132] “Chain 1: Exception: beta_lpdf: First shape parameter is 0, but must be > 0! (in ‘model109862dc13082_Area_and_Hunt_Trend2’ at line 594)”

[133] “Chain 1: If this warning occurs sporadically, such as for highly constrained variable types like covariance matrices, then the sampler is fine,”

[134] “Chain 1: but if this warning occurs often then your model may be either severely ill-conditioned or misspecified.”

[135] "Chain 1: "

[136] “Chain 1: Informational Message: The current Metropolis proposal is about to be rejected because of the following issue:”

[137] “Chain 1: Exception: neg_binomial_2_lpmf: Location parameter is inf, but must be finite! (in ‘model109862dc13082_Area_and_Hunt_Trend2’ at line 754)”

[138] “Chain 1: If this warning occurs sporadically, such as for highly constrained variable types like covariance matrices, then the sampler is fine,”

[139] “Chain 1: but if this warning occurs often then your model may be either severely ill-conditioned or misspecified.”

The line 594 and 754 are again numerical issues related to small values. I have no idea how the parameter declared on line 157 ended up as -nan, but I assume it’s for similar reasons. Needless to say, there is a need for some tweaking of the model, either simplifying it or thinking more carefully about priors that might restrict it from unrealistically small or large values.

Yet, to figure out what has gone wrong, it would have been very useful to look at all the chains, but the outputs have dropped two of the chains. Why is that, and is there anything that can be done to include also the problematic chains in future runs (output files are only half the expected size, so the dropped chains aren’t lurking in the background somewhere)?