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

Utilize previous theta estimate in optimization #16

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@

* Wrap the dispersion variable `phi` in `exp()` to ensure that it is a possible value.

## Improvements

* Now the starting guess for the models parameters, `theta`, is based on the previous round of optimization. This increases the performance and robustness of the paramter estimation.

# aeddo 0.1.1

## Patch
Expand Down
8 changes: 7 additions & 1 deletion R/aeddo.R
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,9 @@ aeddo <- function(
)
}

# Set starting guess for theta
theta <- init_theta # TODO: #17 Implement a method to infer the initial `theta`, `lower`, and `upper`

# Loop over the observations to perform windowed estimation
for (i in 1:(n_observation - k)) {
# Extract data point for this estimation window
Expand Down Expand Up @@ -160,7 +163,7 @@ aeddo <- function(

# Gather all arguments in a list for`do.call()`
optimiser_arguments <- list(
par = init_theta,
par = theta,
data = window_data,
formula = formula,
fn = nll_poisson_gamma,
Expand Down Expand Up @@ -216,6 +219,9 @@ aeddo <- function(
past_outbreaks <- past_outbreaks %>%
dplyr::bind_rows(reference_data)
}

# Set starting guess for theta given last round of optimization
theta <- optimized_param$par * 0.7
}

return(results)
Expand Down