Tweak the initial parameter estimates

tweak_initial_estimates(.mod, .p = 0.1, tweak = c("theta"), digits = 3)

Arguments

.mod

model object to update.

.p

Percent to tweak the initial parameter estimates by. Represented as a decimal.

tweak

type of estimates to tweak in the model. Only "theta" is currently supported, though "omega" and "sigma" will be options at a later date.

digits

Number of significant digits to round estimates to.

Details

In the following cases, the initial estimate will not be updated:

  • Individual FIXED THETA parameters

    • e.g., $THETA 1.2 FIX 1.5 0.2 --> would only skip the first value

  • THETA parameters with no initial estimate

    • e.g., $THETA (0,,1)

For bounded THETA estimates:

  • If an initial THETA has bounds and an initial estimate (e.g., (0, 0.5, 1), (0,1)), the bounds will be respected when sampling a percent to tweak by. If the tweaked value would fall below the lower bound, the initial estimate will be set to 90% of the way between the initial value and lower bound. If after rounding, the value would still not be within the bounds, the difference between the initial value and the bound will be iteratively reduced until it is. The same is true for upper bounds.

    • e.g., (0, 0.5, 1) --> tweak initially, falls outside bound ((0, 1.2, 1)) --> set to value within bounds (first iteration: 0.5 + (1-0.5)*0.9: ((0, 0.95, 1))

Examples

if (FALSE) {
base_mod <- read_model(file.path(MODEL_DIR, "1"))

mod2 <- copy_model_from(base_mod, "mod2") %>%
  tweak_initial_estimates(.p = 0.2)

# This function may be paired with `inherit_param_estimates()`:
mod2 <- copy_model_from(base_mod, "mod2") %>%
  inherit_param_estimates() %>% tweak_initial_estimates(.p = 0.2)

# If you want to set the seed for reproducible results:
mod2 <- withr::with_seed(1234, {
   tweak_initial_estimates(mod2, .p = 0.2, digits = 3)
})

}