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.
simulate_removal_times(
N,
times,
birth_times,
removal_min = 0,
removal_max = max(times),
prob_removal = 0
)
The number of individuals in the simulation
A vector of each time step in the simulation
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
The minimum age at which an individual can be removed from the population. Defaults to 0
The maximum age at which an individual can be removed from the population. Defaults to max(times)
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 be max(times)+1
A vector of all individual's removal times is returned. NA
represents no removal
Other demography:
generate_pop_demography()
,
simulate_birth_times()
## 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 78 101 101 78 89 101 61 101 101 101 101 93 46 101 39 101
#> [19] 101 84 101 81 101 31 101 101 82 81 101 84 85 101 97 94 101 79
#> [37] 101 101 101 53 101 101 101 101 101 101 101 73 90 78 41 101 79 71
#> [55] 101 78 70 101 101 41 101 101 35 101 101 101 101 101 89 40 101 101
#> [73] 101 51 85 101 101 101 101 101 101 67 81 101 101 101 62 95 101 101
#> [91] 101 85 74 101 101 77 101 101 56 101 98 91 101 44 101 101 101 84
#> [109] 101 98 91 101 101 96 82 83 101 101 29 64 101 51 101 32 99 101
#> [127] 68 101 101 93 101 54 101 101 101 85 101 101 101 101 101 101 101 80
#> [145] 101 83 85 51 33 49 101 83 101 101 66 101 101 41 94 101 101 101
#> [163] 101 101 101 101 62 101 20 101 70 101 99 101 101 101 95 79 101 101
#> [181] 101 101 101 81 45 75 101 97 101 101 63 101 101 101 101 62 72 101
#> [199] 94 101 94 67 101 101 46 101 101 89 101 101 97 101 97 101 95 101
#> [217] 101 101 101 101 101 101 97 101 101 93 101 75 101 96 101 55 71 101
#> [235] 101 101 101 101 74 101 101 97 101 101 101 83 101 101 101 101 101 101
#> [253] 101 101 101 101 68 101 101 101 96 56 101 94 101 90 101 101 101 57
#> [271] 101 101 96 87 36 101 73 63 37 60 99 59 101 101 92 101 101 101
#> [289] 32 49 26 101 23 87 101 101 47 101 85 101 92 45 71 32 101 69
#> [307] 101 73 49 101 101 101 86 72 101 101 101 15 28 101 101 101 55 101
#> [325] 101 101 101 101 101 101 101 83 99 101 78 65 26 101 101 101 101 99
#> [343] 101 60 75 74 77 101 101 91 62 101 101 101 101 65 101 101 101 101
#> [361] 71 83 85 97 101 70 101 101 98 60 101 101 101 65 101 97 101 101
#> [379] 85 87 101 51 101 101 101 101 101 51 101 88 51 101 67 78 86 101
#> [397] 55 84 101 34 50 101 101 101 101 101 53 101 94 101 54 101 101 93
#> [415] 101 101 93 101 58 98 91 101 101 96 101 101 75 50 101 79 101 101
#> [433] 101 101 92 101 81 101 101 101 101 101 101 101 101 101 101 101 101 92
#> [451] 101 101 52 101 98 101 101 101 85 98 98 101 101 101 101 101 96 101
#> [469] 88 101 101 79 101 90 74 82 101 101 101 101 91 101 79 94 101 101
#> [487] 101 101 101 101 53 44 101 101 87 65 101 33 101 101