-
Notifications
You must be signed in to change notification settings - Fork 8
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
rbmi 1.3.1: first fit after compiling model not reproducible with subsequent fits #469
Comments
Interestingly, if one saves the random seed in result <- rstan::stan_model(
file = model_file,
auto_write = TRUE,
model_name = "rbmi_mmrm"
)
.Random.seed <<- backup_seed
return(result) seems to fix it. Not sure what in get_stan_model() non-deterministically modifies the seed though. |
Apparently
|
Apparently this comes from processx::get_id(), see
The call stack for this one is quite deep:
|
Apparently this is a known issue in processx: r-lib/processx#386 (and was discovered in pkgbuild, too: r-lib/pkgbuild#185) |
Can confirm that installing the latest processx off Github ( |
@luwidmer - Thanks for the detailed bug report + breakdown ! My gut feeling is that even if this is fixed in the upstream that we should probably apply some fix within rbmi as well as many R setups will have frozen R packages meaning they will still be exposed to this issue. I'm guessing we could just move the random int sampling to be within the |
I tired allocating the seed before, however, this still did not guarantee that the results were the same (at least not in the bitwise sense) - saving .Random.seed and restoring it around the compilation process did work, though |
@luwidmer - Interesting ... I'm semi-guessing but I would assume that comes from the imputation stage when we draw imputed values from the conditional normal. I'd be curious if you re-set the seed before I guess even if that works its not ideal, realistically users should just set the seed once before the first |
Agree. I was also a bit surprised that this has been fixed on processx Github since half a year and is still broken on CRAN |
https://cran.r-project.org/web/packages/processx/index.html processx 3.8.5 fixes this too now :) |
Describe the bug
When fitting the rbmi model for the first time and the model is initially compiled, the results differ from subsequent fits. Is it possible the compilation process has some side effects (e.g., changing the seed)?
Update: it does indeed look like the seed that is set is different.
To Reproduce
Created on 2025-01-06 with reprex v2.1.1
Session info
Screenshots
If applicable, add screenshots to help explain your problem.
Environment (please complete the following information):
The text was updated successfully, but these errors were encountered: