View source: R/rfsrc.RNGversion.R
| rfsrc.RNGversion | R Documentation |
Select or query the random number generator (RNG) seed initialization
protocol used to grow new forests with rfsrc.
Most users do not need to call this function. New forests use the
recommended wide generator by default. Set the RNG version only to
reproduce or test legacy behavior.
rfsrc.RNGversion(version)
version |
A character string: |
Use of the legacy generator is not recommended for new analyses.
Select "3.2.3" only when reproducing or testing legacy behavior;
otherwise use the default, "3.10.0".
The selection is stored in the R session option rf.rng.version.
When that option is unset, new forests use "3.10.0". Functions
that grow forests through rfsrc() in the same R session inherit
this setting. Independent R sessions, including separate worker or
test processes, must set their own selection.
Each newly grown forest records its selection in
fit$forest$rng.version. Restoration, prediction, partial
dependence, and variable importance use the saved forest's protocol,
regardless of the current session setting. Forests without RNG
metadata use the legacy protocol, "3.2.3".
These identifiers select the package's seed-head protocol. Selecting
a protocol does not set a seed, change R's RNGkind,
or alter .Random.seed. Use the seed argument to
rfsrc() or set.seed to control the seed.
The legacy identifier marks the earliest supported RNG compatibility baseline, including variable importance. Selecting it does not restore other historical package defaults or guarantee identical results after unrelated algorithm changes.
With no argument, the current effective RNG version as a character
string. When setting or resetting the selection, the previous stored
option is returned invisibly. This is NULL when no override
was set, allowing the previous setting to be restored with another
call to rfsrc.RNGversion().
Hemant Ishwaran and Udaya B. Kogalur
rfsrc,
RNGversion,
set.seed
## Only for reproducing or testing legacy behavior.
local({
previous <- rfsrc.RNGversion("3.2.3")
on.exit(rfsrc.RNGversion(previous))
fit <- rfsrc(Sepal.Length ~ ., iris, ntree = 25, seed = -1234)
print(fit$forest$rng.version)
## Return to the recommended wide generator for subsequent fits.
rfsrc.RNGversion("3.10.0")
print(rfsrc.RNGversion())
## The existing forest keeps its original protocol.
print(fit$forest$rng.version)
## Remove the session override.
rfsrc.RNGversion(NULL)
print(rfsrc.RNGversion())
})
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.