This function simulates uniformly distributed removal times for a specified number of individuals from the provided times vector. This might represent e.g., death or study attrition.
Usage
simulate_removal_times(
N,
times,
birth_times,
removal_min = 0,
removal_max = max(times),
prob_removal = 0
)
Arguments
- N
The number of individuals in the simulation
- times
A vector of each time step in the simulation
- birth_times
A vector of birth times for each individual; defaults to NULL; if
birth_times
is not specified then the function will simulate uniformly distributed birth times for each individual from the times vector- removal_min
The minimum age at which an individual can be removed from the population. Defaults to 0
- removal_max
The maximum age at which an individual can be removed from the population. Defaults to
max(times)
- prob_removal
The probability that an individual will be removed from the population during the simulation, representing e.g., death or study attrition. If set to
NA
, then removal time will bemax(times)+1
See also
Other demography:
generate_pop_demography()
,
simulate_birth_times()
Examples
## Simulate random removal times for all individuals; Individuals have a 0.4 probability
## of being removed at some time after they are 10 time steps old and before
## they are 99 time steps old
birth_times<-simulate_birth_times(500, 1:100, age_min=9)
simulate_removal_times(500,1:100,birth_times, removal_min=10,removal_max=99, prob_removal=0.4)
#> [1] 101 101 99 50 101 69 101 101 101 101 87 92 101 101 55 101 101 101
#> [19] 74 101 101 98 59 101 44 89 34 85 52 96 61 101 89 101 101 101
#> [37] 40 78 19 101 101 101 101 86 101 101 84 101 101 101 101 86 80 54
#> [55] 101 92 101 101 96 67 101 101 94 101 29 83 65 101 73 39 101 56
#> [73] 101 101 101 101 101 80 101 87 101 101 86 95 62 101 101 101 101 101
#> [91] 101 67 101 72 101 86 101 101 101 72 91 101 101 36 65 51 101 101
#> [109] 90 63 101 101 101 53 84 54 67 67 99 101 101 67 101 91 101 101
#> [127] 101 101 101 92 79 101 101 101 101 101 83 101 101 101 61 35 101 84
#> [145] 14 101 47 70 101 101 101 101 101 101 85 101 101 101 82 101 101 101
#> [163] 92 39 76 101 101 101 93 101 101 95 101 101 98 101 56 44 101 88
#> [181] 101 72 101 101 101 49 101 70 97 101 101 101 101 92 101 101 70 101
#> [199] 101 101 98 99 101 101 101 66 52 101 101 101 88 30 101 101 101 99
#> [217] 101 88 89 89 101 85 47 101 101 101 93 94 101 101 95 101 101 78
#> [235] 101 54 101 101 101 101 101 101 87 101 101 101 101 90 101 101 80 101
#> [253] 98 101 87 79 101 82 96 98 101 101 101 46 101 98 83 101 101 101
#> [271] 98 83 69 25 21 101 101 101 58 69 68 101 101 101 76 101 101 86
#> [289] 101 101 101 101 101 74 74 98 101 101 91 101 45 101 89 69 96 101
#> [307] 64 101 101 101 101 101 101 101 90 101 101 101 101 101 101 101 101 101
#> [325] 101 101 101 101 101 101 101 101 101 101 54 101 59 101 101 92 101 86
#> [343] 51 101 85 101 101 101 101 99 101 74 85 84 70 101 38 101 101 101
#> [361] 101 57 64 101 101 101 101 101 101 83 44 89 101 81 101 101 101 101
#> [379] 59 101 83 101 96 101 70 101 101 52 101 101 101 101 101 101 101 101
#> [397] 67 101 101 101 101 68 101 101 101 63 101 101 62 93 101 83 101 101
#> [415] 101 101 88 101 101 77 50 101 101 64 101 24 81 101 101 101 101 92
#> [433] 85 101 28 76 101 98 101 101 96 70 93 101 101 101 101 101 101 37
#> [451] 101 37 101 90 69 101 99 101 91 49 93 101 101 101 82 88 101 69
#> [469] 101 35 101 101 48 42 101 101 101 99 101 54 101 86 101 101 101 101
#> [487] 101 99 101 60 94 101 101 101 94 101 101 101 68 101