Skip to contents

Estimate a copula's dependence parameter(s) – and, when a marginal names a family without parameters, that marginal's own parameters – from a paired sample. Mirrors the C# BivariateCopulaEstimation methods of the Numerics library.

Usage

copula_fit(
  family,
  x,
  y,
  method = c("mpl", "ifm", "mle", "tau"),
  margin_x = NULL,
  margin_y = NULL
)

Arguments

family

one of copula_names().

x, y

numeric vectors of raw paired observations, the same length.

method

"mpl" (maximum pseudo-likelihood, the default), "ifm" (inference from margins), "mle" (full maximum likelihood), or "tau" (Kendall's tau inversion; Clayton, Gumbel, and AliMikhailHaq only).

margin_x, margin_y

optional marginals; see Details.

Value

a fitted corehydro_copula.

Details

x and y are the raw paired observations for every method. method = "mpl" maximizes the pseudo-likelihood, which is defined on the plotting positions rank / (n + 1) rather than on the data scale; that transform happens inside the shared C++ core, so R and Python fit the same numbers from the same input.

margin_x and margin_y accept EITHER a family-name string or a corehydro_dist, and the two are handled differently:

  • a name (e.g. margin_x = "Normal") is fitted by maximum likelihood to x (or y) before the copula is estimated. This is what Inference From Margins (method = "ifm") requires, and it is accepted for "ifm" and "mle" only: "mpl" and "tau" ignore the marginals entirely, so a name there would be reported back unfitted.

  • a corehydro_dist (e.g. margin_x = distribution("Normal", c(0, 1))) is accepted for all four methods. "mpl" and "tau" attach it untouched (so copula_random() can draw on the data scale), "ifm" takes it as the given margin, and "mle" re-estimates it jointly with theta.

method = "tau" inverts Kendall's tau into theta directly and is only implemented upstream for Clayton, Gumbel, and AliMikhailHaq (SetThetaFromTau); it errors for every other family.

Examples

x <- c(135.9, 104.1, 108.7, 99.3, 134.7, 91.0, 77.3, 115.4, 109.0, 79.0)
y <- c(1.9, 1.3, 1.4, 1.2, 1.8, 1.1, 0.9, 1.5, 1.4, 1.0)
copula_fit("Clayton", x, y, method = "mpl")
#> <corehydro_copula> Clayton(theta = 65.2289)