Fit a model by maximum likelihood and return a fit object carrying the parameter estimates,
the Hessian-based covariance, and optimizer bookkeeping. Wraps the shared C++
MaximumLikelihood ported from USACE-RMC RMC.BestFit.
Usage
fit_mle(
model,
distribution = NULL,
optimizer = "NelderMead",
hessian = TRUE,
profile = FALSE,
profile_bins = 100
)Arguments
- model
a
model_univariate()(or anymodel_*()) object, or a plain numeric vector of observations together withdistribution. A model can bring censored observations (seeanalysis_data()), nonstationary trends (seetrend()), and parameter bounds or priors (seemodel_parameter()).- distribution
distribution family name, required only when
modelis a numeric vector.- optimizer
one of
"NelderMead"(default),"Brent","BFGS","Powell","DifferentialEvolution","MultilevelSingleLinkage".- hessian
logical; compute the covariance, standard errors and correlation.
TRUEby default. A model with fewer than two parameters reportsNaNfor all three.- profile
logical; also compute the profile likelihood and profile confidence intervals.
FALSEby default because each costsprofile_bins * length(parameters)likelihood evaluations.- profile_bins
number of bins in each parameter's profile.
Value
An object of class corehydro_fit. When profile = TRUE, it also carries $profile,
a named list (one entry per parameter, named to match coef()) of profile_bins-by-2
matrices with columns value and log_likelihood, the profile-likelihood grid confint()'s
intervals are drawn from – plot a parameter's curve with e.g.
plot(f$profile[[1]], type = "l"). Absent (NULL) when the fit was built with the default
profile = FALSE. See fit_bayesian() for the Bayesian surface.
Examples
peaks <- c(12500, 15300, 8900, 22100, 18700, 14200, 9800, 28500, 17400, 11600)
f <- fit_mle(model_univariate("LogPearsonTypeIII", peaks))
coef(f)
#> Mean (of log) (µ) Std Dev (of log) (σ) Skew (of log) (γ)
#> 4.1750940 0.1570368 0.8611540
AIC(f)
#> [1] 205.0056