Simulate a from a Poisson process

rxPp(
  n,
  lambda,
  gamma = 1,
  prob = NULL,
  t0 = 0,
  tmax = Inf,
  randomOrder = FALSE
)

Arguments

n

Number of time points to simulate in the Poisson process

lambda

Rate of Poisson process

gamma

Asymmetry rate of Poisson process. When gamma=1.0, this simulates a homogenous Poisson process. When gamma<1.0, the Poisson process has more events early, when gamma > 1.0, the Poisson process has more events late in the process.

When gamma is non-zero, the tmax should not be infinite but indicate the end of the Poisson process to be simulated. In most pharamcometric cases, this will be the end of the study. Internally this uses a rate of:

l(t) = lambdagamma(t/tmax)^(gamma-1)

prob

When specified, this is a probability function with one argument, time, that gives the probability that a Poisson time t is accepted as a rejection time.

t0

the starting time of the Poisson process

tmax

the maximum time of the Poisson process

randomOrder

when TRUE randomize the order of the Poisson events. By default (FALSE) it returns the Poisson process is in order of how the events occurred.

Value

This returns a vector of the Poisson process times; If the dropout is >= tmax, then all the rest of the times are = tmax to indicate the dropout is equal to or after tmax.

Author

Matthew Fidler

Examples


## Sample homogenous Poisson process of rate 1/10
rxPp(10, 1 / 10)
#>  [1]  15.51811  16.57788  29.57097  52.53117  54.02744  56.15175  72.36297
#>  [8]  77.23964 100.56238 117.83316

## Sample inhomogenous Poisson rate of 1/10

rxPp(10, 1 / 10, gamma = 2, tmax = 100)
#>  [1] 15.34403 53.36726 56.67252 65.27753 67.30450 68.50082 77.79207 81.98523
#>  [9] 84.35882 85.41290

## Typically the Poisson process times are in a sequential order,
## using randomOrder gives the Poisson process in random order

rxPp(10, 1 / 10, gamma = 2, tmax = 10, randomOrder = TRUE)
#>  [1] 10 10 10 10 10 10 10 10 10 10

## This uses an arbitrary function to sample a non-homogenous Poisson process

rxPp(10, 1 / 10, prob = function(x) {
  1 / x
})
#>  [1]   1.806933   2.003025   4.475795  28.739301  38.336540  69.627514
#>  [7] 106.499605 203.379857 363.115068 420.011966