Closed waynelapierre closed 3 years ago
Hi Wayne,
The seed is local only and does not affect things outside of the function. Here is the snippet that checks for a global seed and saves it first when entering any function that has the option random.seed=42... once the function is entered the first order of business is:
## Save seed prior to setting
if(exists(".Random.seed", .GlobalEnv)) {
save.seed <- get(".Random.seed", .GlobalEnv)
exists.seed = TRUE
} else {
exists.seed = FALSE
}
set.seed(random.seed)
Then, before exiting the function you will see
## Restore seed
if(exists.seed) assign(".Random.seed", save.seed, .GlobalEnv)
You can always experiment to confirm, but this should reassure you that it won't interfere with replicating simulation experiments that use their own seed.
Jeff
thanks for the clarification!
I would like to ask whether the random.seed in npsigtest local or global. If it is global, then I need to pay attention to my other bootstrap and simulation codes after using the npsigtest function. Thanks.