Learn R Programming

hesim (version 0.5.5)

fast_rgengamma: Random generation for generalized gamma distribution

Description

Draw random samples from a generalized gamma distribution using the parameterization from flexsurv. Written in C++ for speed. Equivalent to flexsurv::rgengamma.

Usage

fast_rgengamma(n, mu = 0, sigma = 1, Q)

Value

A vector of random samples from the generalized gamma distribution. The length of the sample is determined by n. The numerical arguments other than n are recycled so that the number of samples is equal to n.

Arguments

n

Number of random observations to draw.

mu

Vector of location parameters. and columns correspond to rates during specified time intervals.

sigma

Vector of scale parameters as described in flexsurv.

Q

Vector of shape parameters.

Examples

Run this code
n <- 1000
m <- 2 ; s <- 1.7; q <- 1
ptm <- proc.time()
r1 <- fast_rgengamma(n, mu = m, sigma = s, Q = q)
proc.time() - ptm
ptm <- proc.time()
library("flexsurv")
r2 <- flexsurv::rgengamma(n, mu = m, sigma = s, Q = q)
proc.time() - ptm
summary(r1)
summary(r2)

Run the code above in your browser using DataLab