Skip to contents

Fits candidate parametric distributions to each column of X by maximum likelihood and selects the best fit using AIC or BIC, following the methodology in Clavijo Mesa et al. (2026).

Usage

hm_fit_marginals(X, dists = .hm_supported_dists, criterion = "bic")

Arguments

X

A numeric matrix (\(T \times N\)) from [hm_to_matrix()]. All values must be strictly positive.

dists

Candidate families. Any subset of c("weibull", "gamma", "lnorm", "gumbel", "tnorm", "tlaplace").

criterion

Selection criterion: "bic" (default) or "aic".

Value

A data.frame with one row per cell and columns cell_id, best_dist, best_dist_label, params, loglik, aic, bic, n_obs, n_failed, conv_code (0 = converged, see ?optim), and n_iter (number of function evaluations by the optimiser). The attribute "fits_full" stores raw per-cell fit results for use in [hm_marginal_gof()].

See also

[hm_marginal_gof()], [hm_pit_transform()]

Examples

f <- system.file("extdata", "Copernicus_dailymax_1994_2021.nc",
                 package = "HazardMaps")
x <- hm_read_netcdf(f, var = "i10fg")
x <- hm_standardize_coords(x)
x <- hm_decode_time(x)
x_ext <- hm_select_extreme_events(x, threshold = 25)
X     <- hm_to_matrix(x_ext)
if (FALSE) { # \dontrun{
fits <- hm_fit_marginals(X, criterion = "bic")
table(fits$best_dist)
} # }