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

Suggestion: reparametrize before using optim #10

Open
ghost opened this issue Apr 27, 2020 · 4 comments
Open

Suggestion: reparametrize before using optim #10

ghost opened this issue Apr 27, 2020 · 4 comments

Comments

@ghost
Copy link

ghost commented Apr 27, 2020

As the model is parametrized currently, delta is a value between 0 and 1 and theta is a positive value. When fitting the model with optim this sometimes leads to non-convergence. This can easily be fixed by transforming the parameters for the function RSS passed to optim, so that each parameter can take any real value. For example, take the logit of delta and the log of theta, and then back-transform before passing the parameters to the other functions inside RSS. This solves the convergence issues.

@FohmAnalys
Copy link
Owner

Thanks! I will re-parametrise the parameters.

@ghost
Copy link
Author

ghost commented Apr 27, 2020

Here is an example of how it could be done: https://github.com/BenjaK/SEIR-model-Stockholm/blob/master/Script/Estimate_SEIR_for_sharing_new_incidence.R (note that the main function has been renamed to Stockholm_SEIR).

@fredlind
Copy link

fredlind commented May 8, 2020

Men nog ska logit vara
logit <- function(p) {
log(p) - log(1 - p)
}

och inte

logit <- function(p) {
log(p) / log(1 - p)
}
?

@ghost
Copy link
Author

ghost commented May 8, 2020

Whoops! Det stämmer.

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

2 participants