Skip to content

Fix the random seed in the psa_generation vignette (flaky CI) - #230

Merged
feralaes merged 1 commit into
mainfrom
vignette-psa-seed
Nov 12, 2026
Merged

feralaes merged 1 commit into
mainfrom
vignette-psa-seed

Conversation

@feralaes

Copy link
Copy Markdown
Collaborator

Fixes a flaky R CMD check failure. Windows CI on #229 failed in re-building vignette outputs with "This is not a valid transition matrix (entries are not between 0 and 1)".

Cause

  • The psa_generation vignette drew its PSA sample with gen_psa_samp() without a seed, so every build used new random draws.
  • The example model samples the two competing transitions out of Sick (to Healthy, p_S1H ~ Beta(12, 12), and to Sicker, p_S1S2 ~ Beta(15, 133)) independently. Occasionally they sum to more than 1. With seed 297, sample 22 draws 0.899 + 0.102.
  • The model's own check then stops the vignette. This happens in about 1 build in 300, on any platform and on main too.

Fix

  • A visible set.seed() right before the vignette draws its PSA sample, so the build and its results are reproducible. Readers who run the vignette get the same numbers.
  • I rendered the vignette twice locally with the new seed to confirm it builds.

Not fixed here (vignette content, for #216)

The sampling of the competing transitions is the root cause; the seed only avoids the bad draw. I've described the issue and options on #216, the vignette overhaul.

The vignette drew its PSA sample without a seed, so every build used new
random draws. About 1 build in 300 drew p_S1H + p_S1S2 > 1 (for example
seed 297: 0.899 + 0.102), the example model then stopped with 'This is
not a valid transition matrix', and R CMD check failed (seen on Windows
CI for #229). Setting the seed makes the vignette build and its results
reproducible.
@feralaes
feralaes merged commit c5e4d49 into main Nov 12, 2026
9 checks passed
@feralaes
feralaes deleted the vignette-psa-seed branch November 12, 2026 22:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant