Simulate a from a Poisson process
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.
Examples
## Sample homogenous Poisson process of rate 1/10
rxPp(10, 1 / 10)
#> [1] 1.560519 2.393774 12.691104 12.832895 12.985304 18.294459 27.409655
#> [8] 28.833302 29.132053 30.549960
## Sample inhomogenous Poisson rate of 1/10
rxPp(10, 1 / 10, gamma = 2, tmax = 100)
#> [1] 11.53112 15.12508 21.31092 28.89251 42.05832 46.36393 51.14902 76.31013
#> [9] 82.12071 90.82746
## 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] 0.6174213 10.0000000 10.0000000 10.0000000 10.0000000 10.0000000
#> [7] 10.0000000 6.9951306 10.0000000 10.0000000
## This uses an arbitrary function to sample a non-homogenous Poisson process
rxPp(10, 1 / 10, prob = function(x) {
1 / x
})
#> Error: 'prob' function should return values between 0 and 1