Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoiding unnecessary discretization in r2R0 #26

Open
tamas-ferenci opened this issue Mar 16, 2020 · 1 comment
Open

Avoiding unnecessary discretization in r2R0 #26

tamas-ferenci opened this issue Mar 16, 2020 · 1 comment

Comments

@tamas-ferenci
Copy link

In parametric approach, serial interval is typically assumed to have Gamma distribution, so it would be perhaps useful to include a function

r2R0gamma <- function(r, si_mean, si_sd) {
  (1+r*si_sd^2/si_mean)^(mu^2/sigma^2)
}

in the package. Even the example of r2R0 is not really fortunate as it starts from mu and sigma being known, yet, it first transforms them to a discretized distribution, and then uses the empirical distribution formula from Wallinga and Lipitsch, which is obviously a convoluted approach, with a loss of precision.

As a comparison, r2R0 gives the values

[1]  0.0000000  0.9852657  1.0000000  1.0148667 98.7061545

for the example, while the true values according to my calculation are

[1]         NaN   0.9847737   1.0000000   1.0153739 168.8621648
@tamas-ferenci
Copy link
Author

We could even have something like

r2R0parametric <- function(r, dist, ...) {
  if(!exists(paste0("mgf", dist), where = asNamespace("actuar")))
    stop(paste0("There is no moment generating function for ", dist, " in actuar package!"))
  1/do.call(get(paste0("mgf", dist), asNamespace("actuar")), list(t = -r, ...))
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant