stanbkt.fits.MLEFitOptions#

class stanbkt.fits.MLEFitOptions(seed=None, extra_kwargs=<factory>, algorithm=None, iter=2000, jacobian=False, tol_obj=None, tol_rel_obj=None, tol_grad=None, tol_rel_grad=None, tol_param=None, history_size=None)#

Bases: BaseFitOptions

Common options for cmdstanpy.CmdStanModel.optimize().

Parameters:
  • algorithm (str | None) – Optimization algorithm (for example, "lbfgs", "bfgs", or "newton").

  • iter (int) – Maximum number of optimization iterations.

  • jacobian (bool) – Whether to include Jacobian adjustment for constrained parameters.

  • tol_obj (float | None) – Convergence tolerance on changes in objective function value.

  • tol_rel_obj (float | None) – Convergence tolerance on relative changes in objective function value.

  • tol_grad (float | None) – Convergence tolerance on the norm of the gradient.

  • tol_rel_grad (float | None) – Convergence tolerance on the relative norm of the gradient.

  • tol_param (float | None) – Convergence tolerance on changes in parameter value.

  • history_size (int | None) – History size for the L-BFGS Hessian approximation. Values of 5–10 are usually sufficient; must be less than the parameter-space dimensionality.

  • seed (int | None) – RNG seed for reproducibility.

  • extra_kwargs (dict[str, Any])

algorithm: str | None = None#
extra_kwargs: dict[str, Any]#
classmethod from_dict(d)#

Create fit options from a dictionary.

Known dataclass fields are extracted and used for instantiation. Remaining keys are stored in extra_kwargs for CmdStanPy.

Parameters:

d (dict[str, Any]) – Dictionary containing fit options. Keys matching dataclass fields are assigned to those fields; remaining keys go to extra_kwargs.

Returns:

New instance of the fit options class with fields populated from dict.

Return type:

Self

history_size: int | None = None#
iter: int = 2000#
jacobian: bool = False#
seed: int | None = None#
to_dict()#

Convert options to a CmdStanPy kwargs dictionary.

None values are removed so CmdStanPy can apply its own defaults.

Returns:

Flat kwargs dictionary for CmdStanPy APIs.

Return type:

dict[str, Any]

tol_grad: float | None = None#
tol_obj: float | None = None#
tol_param: float | None = None#
tol_rel_grad: float | None = None#
tol_rel_obj: float | None = None#