Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Seeds #286

Merged
merged 9 commits into from
Mar 8, 2022
Merged

Seeds #286

merged 9 commits into from
Mar 8, 2022

Conversation

fweber144
Copy link
Collaborator

With this PR, the seed supplied to top-level (user-facing) functions is used to generate new seeds for downstream code on-the-fly. The main advantage of this is that PRNG-using code may be added more easily (which will be important for fixing issue #268) and it also helps to avoid using the same seed multiple times, where possible (see the message of commit 6ed82b6).

Furthermore, seed (and .seed) arguments now have a default of sample.int(.Machine$integer.max, 1) instead of NULL which allows users to set a seed once at the beginning of their script and then use the default seed (and .seed) arguments.

If this is merged after the upcoming CRAN release, the version number for the NEWS.md change performed here needs to be adapted.

downstream code on-the-fly.

The approach implemented now changes the default of `seed` (and `.seed`) arguments from `NULL` to `sample.int(.Machine$integer.max, 1)`. For top-level functions which are only called by the user and not within projpred (should only be `cv_varsel()`, `project()`, and `proj_predict()`), this is not strictly necessary, but done for consistency with lower-level functions which are also called within projpred.

The main advantage of generating seeds on-the-fly is that more seeds may be easily added and used in downstream code (which will be important for fixing issue stan-dev#268), without always having to add a new argument to top-level functions. Apart from that, this approach makes it possible that users set a seed once at the beginning of their script and then use the default `seed` (and `.seed`) arguments -- they will then get reproducible results which would not have been the case for the former implementation.

However, due to the resetting of `.Random.seed`, this approach does not avoid yet that the same seed is re-used multiple times (which is probably bad practice from a theoretical point of view).
`.get_p_clust()` and in a new function for subsampling the parameter draws
(`draws_subsample()`). This is only done for conceptual reasons (to point out
where the seed is actually used).
`Error in qr.solve(decomposition, Q) : singular matrix 'a' in solve`
in the K-fold CV for refmodel
`rstanarm.glm.brnll.stdformul.without_wobs.without_offs`, perhaps due to
unfortunate PRNG leading to linear separability).
reason is that this was probably done on purpose, so that the variable selection
with all the data uses the same clustering (of the draws) as the variable
selection(s) in `loo_varsel()` and `kfold_varsel()`.
the beginning of which a seed is set), don't reset the RNG state on exit. Consequently, at those places, a seed does not even need to be set. However, the latter is just a simplification. The important point is that the RNG state is not reset on exit which avoids that the same seed is re-used multiple times (which is probably bad practice from a theoretical point of view).
@AlejandroCatalina AlejandroCatalina merged commit 5ad114c into stan-dev:develop Mar 8, 2022
@fweber144 fweber144 deleted the seeds branch March 9, 2022 09:35
fweber144 added a commit that referenced this pull request Apr 23, 2022
`predict.refmodel()`. In the future, it may be needed at other places, too. And
with the new seed behavior of projpred (see PR #286), K-fold CV might actually
be reproducible even if `brms_seed` is not set (I did not test this, though). So
it's probably best to only vaguely hint at argument `brms_seed` in the vignette.
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.

None yet

2 participants