Skip to contents

Fit a model_bulletin17c() model by the generalized method of moments and return a fit object carrying the parameter estimates, the sandwich covariance, and the J-statistic overidentification test. Wraps the shared C++ GeneralizedMethodOfMoments ported from USACE-RMC RMC.BestFit – the same estimator bulletin17c_analysis() builds on. IGMMModel (the interface GMM fits against) has exactly one implementation, Bulletin17CDistribution, so fit_gmm() takes only a model_bulletin17c() model; unlike fit_mle()/fit_map() there is no plain-vector-plus-distribution convenience path.

Usage

fit_gmm(
  model,
  optimizer = "BFGS",
  strategy = "Iterative",
  max_gmm_iterations = 0L
)

Arguments

model

a model_bulletin17c() object.

optimizer

one of "BFGS" (default, matching GeneralizedMethodOfMoments's own class default), "NelderMead", "Brent", "Powell", "DifferentialEvolution", "MultilevelSingleLinkage".

strategy

GMM estimation strategy: "Iterative" (default), "OneStep", or "TwoStep".

max_gmm_iterations

maximum number of GMM iterations; 0 (default) keeps the estimator's own default cap.

Value

An object of class corehydro_fit with method == "GMM". Method of moments computes no likelihood surface, so $log_likelihood, $aic and $bic are NA; $nobs is the record length the estimator fitted against. Bulletin 17C is always just-identified (as many moment conditions as parameters), so $j_stat_pval is structurally NA – there is no over-identified case to report a p-value for (see docs/upstream-csharp-issues.md). $gmm_iterations, $converged_within_tolerance, and $optimizer_fallback_count carry the estimator's own bookkeeping. See quantile_variance() for the delta-method variance of a fitted quantile, and fit_diagnostics() for leverage/influence diagnostics off a GMM fit.

Examples

peaks <- c(12500, 15300, 8900, 22100, 18700, 14200, 9800, 28500, 17400, 11600)
f <- fit_gmm(model_bulletin17c(peaks))
f$parameters
#>        p1        p2        p3 
#> 4.1750592 0.1578614 0.2965010 
quantile_variance(f, 0.01)
#> [1] 0.02280342