Description Usage Arguments Value Author(s) Examples
Generates a waiting time following an exponential or Weibull distribution with
constant or varying rates. Allows for an optional shape parameter, in which
case lambda
will be taken as a Weibull scale. Allows for information on
the current time, to consider only rates starting from then, and the speciation
time, optionally, in case shape is provided, as the process is agedependent.
Allows for customization on the possibility of throwing away waiting times
higher than tMax
, and therefore takes that time as a parameter.
1 
n 
The number of waiting times to return. Usually 1, but we allow for
a higher 
lambda 
The rate parameter for the exponential distribution. If

now 
The current time. Needed if one wants to consider only the interval
between the current time and the maximum time for the timevarying rate.
Note this does means the waiting time is 
tMax 
The simulation ending time. If the waiting time would be too
high, we return 
shape 
Shape of the Weibull distribution. This will be when smaller than
one, rate will decrease along species' age (negative agedependency). When
larger than one, rate will increase along each species's age (positive
agedependency). Default is Note: Timevarying shape is implemented, so one could have 
TS 
Speciation time, used to account for the scaling between simulation
and species time. The default is 
fast 
If set to 
A vector of waiting times for the exponential or weibull distribution with the given parameters.
Bruno do Rosario Petrucci.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190  ###
# let us start by checking a simple exponential variable
# rate
lambda < 0.1
# current time
now < 0
# maximum time to check
tMax < 40
# get waiting time
t < rexp.var(n = 1, lambda, now, tMax)
t
###
# another simple exponential
# rate
lambda < 0.5
# current time
now < 0
# maximum time to check
tMax < 40
# find the waiting time
t < rexp.var(n = 1, lambda, now, tMax)
t
###
# now let us try a linear function for the rate
# rate
lambda < function(t) {
return(0.01*t + 0.1)
}
# current time
now < 0
# maximum time to check
tMax < 40
# find the waiting time
t < rexp.var(n = 1, lambda, now, tMax)
t
###
# what if lambda is exponential?
# rate
lambda < function(t) {
return(0.01 * exp(0.1*t) + 0.02)
}
# current time
now < 0
# maximum time to check
tMax < 40
# find the waiting time
t < rexp.var(n = 1, lambda, now, tMax)
t
###
# rexp.var also works for a weibull
# scale
lambda < 2
# shape
shape < 1
# current time
now < 0
# maximum time to check
tMax < 40
# speciation time
TS < 0
# find the vector of waiting time
t < rexp.var(n = 1, lambda, now, tMax,
shape = shape, TS = TS)
t
###
# when shape = 1, the Weibull is an exponential, we could do better
# scale
lambda < 10
# shape
shape < 2
# current time
now < 0
# maximum time to check
tMax < 40
# speciation time
TS < 0
# find the vector of waiting times  it doesn't need to be just one
t < rexp.var(n = 5, lambda, now, tMax,
shape = shape, TS = TS)
t
###
# shape can be less than one, of course
# scale
lambda < 10
# shape
shape < 0.5
# current time
now < 3
# maximum time to check
tMax < 40
# speciation time  it will be greater than 0 frequently during a simulation,
# as it is used to represent where in the species life we currently are and
# rescale accordingly
TS < 2.5
# find the vector of waiting times
t < rexp.var(n = 3, lambda, now, tMax,
shape = shape, TS = TS)
t
###
# both lambda and shape can be time varying for a Weibull, but since we have
# only been able to test timevarying lambda effectively, we do not recommend
# using shape as a function
# scale
lambda < function(t) {
return(0.25*t + 5)
}
# shape
shape < 3
# current time
now < 0
# maximum time to check
tMax < 40
# speciation time
TS < 0
# find the vector of waiting times  it doesn't need to be just one
t < rexp.var(n = 5, lambda, now, tMax,
shape = shape, TS = TS)
t
###
# lambda can be any function of time, remember
# scale
lambda < function(t) {
return(0.2*exp(0.1*t) + 5)
}
# shape
shape < 3
# current time  remember lambda will only be considered starting from time now
now < 2.5
# maximum time to check
tMax < 40
# speciation time
TS < 1.2
# find the vector of waiting times  it doesn't need to be just one
t < rexp.var(n = 2, lambda, now, tMax,
shape = shape, TS = TS)
t

Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.