library(serocalculator)
library(dplyr)
#>
#> Attaching package: 'dplyr'
#> The following objects are masked from 'package:stats':
#>
#> filter, lag
#> The following objects are masked from 'package:base':
#>
#> intersect, setdiff, setequal, union
set.seed(1)
n = 480
lambda = 0.036
age = runif(n = n, min = 0, max = 80)
S1 = S2 = rep(0, n)
for (i in 1:n)
{
a = 0
while(S2[i] < age[i])
{
delta = rexp(n = 1, rate = lambda)
S2[i] = S2[i] + delta
}
S1[i] = S2[i] - delta
}
data = tibble(
age,
S1,
S2,
W = S2 - S1,
T1 = age - S1,
`min(W,age)` = min(W, age),
rel = T1/`min(W,age)`
)
hist(data$T1, breaks = 50)
![](simulation_files/figure-html/unnamed-chunk-2-1.png)
hist(data$rel, breaks = 50)
![](simulation_files/figure-html/unnamed-chunk-2-2.png)