optim_search_p_value: Optimization using optim() for optimal p_value

View source: R/14.2.3-strategy-optim.R

optim_search_p_valueR Documentation

Optimization using optim() for optimal p_value

Description

Uses R's optim to find the p_value that minimises the absolute difference between the simulated metric and the target value.

Usage

optim_search_p_value(
  target_value,
  fit_type,
  simulation_function,
  method = "Brent",
  lower = 0.01,
  upper = 5,
  hessian = FALSE
)

Arguments

target_value

Target value (final weight or total consumption)

fit_type

Type of fitting ("weight" or "consumption")

simulation_function

Function that runs simulation and returns metric

method

Optimization method ("Brent", "L-BFGS-B", etc.)

lower

Lower bound for p_value search, default 0.01

upper

Upper bound for p_value search, default 5.0

hessian

Whether to compute Hessian for standard errors, default FALSE

Value

List with fitted p_value and convergence information


fb4package documentation built on May 8, 2026, 1:07 a.m.