Description Usage Arguments Examples
A function for generating event times from a continuous rate function. For speed it requires the integral of the rate function. This can easily be zero inflated but will only keep the zero inflation if t0 = 0. It uses a random number from the uniform distribution followed by a binary search for the event time.
1 | arrivalTimeContinuous(fun, t0 = 0, tmax = 10, acc = 0.05)
|
fun |
A function for the integral of the rate parameter. This should take exactly one input value for the time |
t0 |
The time of the last arrival |
tmax |
The length of time to do the search in it will return a value in the interval t0 + tmax - acc < time < t0 + tmax if the time is right censored by tmax. |
acc |
The size of the interval to search for. The middle value of the interval is returned |
1 2 3 4 5 6 7 8 9 10 11 12 | # start time of 5 showing that for function(x) = x it matches the exponential distribution.
integralFun = function(x) x
par(mfrow = c(1,2))
hist(sapply(1:10000,function(x) arrivalTimeContinuous(integralFun,5,15)), freq = FALSE, breaks = 20,
main = "Using arrivalTimeContinuous")
hist(rexp(10000,1), freq = FALSE, breaks = 20, main = "Using rexp")
integralFun = function(x) x^2/2
par(mfrow = c(1,2))
hist(sapply(1:10000,function(x) arrivalTimeContinuous(integralFun)), freq = FALSE, breaks = 20,
main = "Using arrivalTimeContinuous")
hist(rexp(10000,1), freq = FALSE, breaks = 20, main = "Using rexp")
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.