CDCgov / ww-inference-model

An in-development R package and a Bayesian hierarchical model jointly fitting multiple "local" wastewater data streams and "global" case count data to produce nowcasts and forecasts of both observations
https://cdcgov.github.io/ww-inference-model/
Apache License 2.0
17 stars 2 forks source link

R PRNG seeding when `generate_random_inits = TRUE`? #107

Closed dylanhmorris closed 2 months ago

dylanhmorris commented 2 months ago

https://github.com/CDCgov/ww-inference-model/blob/410857b4634d31df7585060082d9c2dc539b7bbf/R/wwinference.R#L121-L126

We should either build in functionality for optional seed setting as an argument to wwinference or explicitly direct the user to run wwinference in the context of an explicitly seeded PRNG if they want reproducible results.

@kaitejohnson @seabbs

dylanhmorris commented 2 months ago

My inclination would be both/and: init PRNG seed is default NULL, so that this works:

   wwinference(<args>, generate_initial_values = TRUE, initial_values_seed = 2)

But so does this:

withr::with_seed(5, {
   wwinference(<args>, generate_initial_values = TRUE, initial_values_seed = NULL
})

Open to counterarguments / alternative suggestions.

kaitejohnson commented 2 months ago

I think this is reasonable to me! I can go head and implement this. My prference will be for this syntax in the vignette: wwinference(<args>, generate_initial_values = TRUE, initial_values_seed = seed)

where we set the seed at the top of the vignette

@dylanhmorris this is dependent on changes in #58, so will likely wait for that to be merged unless I should just branch off of it. This is where I never know whats best to do with cascading issues/PRs