fit_mle

fit_mle(
    model,
    distribution=None,
    optimizer='NelderMead',
    hessian=True,
    profile=False,
    profile_bins=100,
)

Maximum likelihood fit.

Fit a model by maximum likelihood and return a fit carrying the parameter estimates, the Hessian-based covariance, and optimizer bookkeeping. Wraps the shared C++ MaximumLikelihood ported from USACE-RMC RMC.BestFit.

Parameters

Name Type Description Default
model Model or array_like A :func:~corehydropy.model_univariate (or any model_*()) object, or a plain sequence of observations together with distribution. A model can bring censored observations (see :class:~corehydropy.AnalysisData), nonstationary trends (see :func:~corehydropy.trend), and parameter bounds or priors (see :func:~corehydropy.model_parameter). required
distribution str Distribution family name, required only when model is a plain sequence. None
optimizer str One of "NelderMead", "Brent", "BFGS", "Powell", "DifferentialEvolution", "MultilevelSingleLinkage". "NelderMead"
hessian bool Compute the covariance, standard errors, and correlation. A model with fewer than two parameters reports nan for all three. True
profile bool Also compute the profile likelihood and profile confidence intervals. Costs profile_bins * len(parameters) likelihood evaluations. False
profile_bins int Number of bins in each parameter’s profile. 100

Returns

Name Type Description
Fit When profile is True, .profile is a dict (one entry per parameter, keyed to match .parameters) of profile_bins x 2 arrays with columns [value, log_likelihood] – the profile-likelihood grid Fit.confint’s intervals are drawn from. None otherwise. See :func:fit_bayesian for the Bayesian surface.

See Also

fit_map, fit_bayesian, fit_gmm, fit_diagnostics

Examples

>>> from corehydropy import fit_mle, model_univariate
>>> peaks = [12500, 15300, 8900, 22100, 18700, 14200, 9800, 28500, 17400, 11600]
>>> f = fit_mle(model_univariate("LogPearsonTypeIII", peaks))
>>> sorted(f.parameters)