Learn R Programming

TPmsm (version 1.2.0)

setPackageSeedTP: Set the initial package seed

Description

The random number generator (RNG) with multiple independent streams developed by L'Ecuyer et al. (2002) is used for parallel computation of uniform pseudorandom numbers. Package TPmsm makes extensive use of uniform pseudorandom numbers, particularly for the bootstrapping statistical techniques and for the generation of univariate and multivariate pseudorandom data. This function defines the seed for the creation of RNG streams.

Usage

setPackageSeedTP(seed=12345)

Arguments

seed
A vector of one to six integers. Defaults to rep(x=12345, times=6).

Value

  • Invisibly returns NULL.

encoding

UTF-8

Details

If the user defines a vector with length lower than six as seed, then the seed is internally defined as a vector of length six with the first elements equal to the user defined values, and the leaving elements equal to 12345. If a vector with more than six elements is provided as seed, then only the first six elements are used.

References

Karl A. T., Eubank R., Milovanovic J., Reiser M., Young D. (2014) Using RngStreams for parallel random number generation in C++ and R. Computational Statistics 29(5), 1301--1320.

L'Ecuyer, P. (1999) Good parameters and implementations for combined multiple recursive random number generators. Operations Research 47(1), 159–-164.

L’Ecuyer P., Simard R., Chen E. J., Kelton W. D. (2002) An object-oriented random-number package with many long streams and substreams. Operations Research 50(6), 1073–-1075.

See Also

setSeedTP.

Examples

Run this code
# Set the number of threads
nth <- setThreadsTP(2)

# Define package seed
seed <- rep(x=1, times=6)

# Set package seed
setPackageSeedTP(seed)

# Create survTP object
data(heartTP)
heartTP_obj <- with(heartTP, survTP(time1, event1, Stime, event))

# Compute transition probabilities with confidence band
TPmsm0 <- transAJ(object=heartTP_obj, s=33, t=412, conf=TRUE,
conf.level=0.9, method.boot="percentile")

# Compute transition probabilities with confidence band
TPmsm1 <- transAJ(object=heartTP_obj, s=33, t=412, conf=TRUE,
conf.level=0.9, method.boot="percentile")

# The objects should be different
all.equal(TPmsm0, TPmsm1)

# Set package seed
setPackageSeedTP(seed)

# Compute transition probabilities with confidence band
TPmsm2 <- transAJ(object=heartTP_obj, s=33, t=412, conf=TRUE,
conf.level=0.9, method.boot="percentile")

# Both objects were computed from the same seed and should be equal
all.equal(TPmsm0, TPmsm2)

# Restore the number of threads
setThreadsTP(nth)

Run the code above in your browser using DataLab