dcopula: Joint density under a bivariate copula

View source: R/copulas.R

dcopulaR Documentation

Joint density under a bivariate copula

Description

Computes the joint density (or log-density) of a bivariate distribution constructed from two arbitrary margins combined with a specified copula.

Usage

dcopula(d1, d2, p1, p2, copula = cgaussian(0), log = FALSE)

Arguments

d1, d2

Marginal density values. If log = TRUE, supply the log-density. If log = FALSE, supply the raw density.

p1, p2

Marginal CDF values. Need not be supplied on log scale.

copula

A function of two arguments (u, v) returning the log copula density \log c(u,v). You can either construct this yourself or use the copula constructors available (see details)

log

Logical; if TRUE, return the log joint density. In this case, d1 and d2 must be on the log scale.

Details

The joint density is

f(x,y) = c(F_1(x), F_2(y)) \, f_1(x) f_2(y),

where F_i are the marginal CDFs, f_i are the marginal densities, and c is the copula density.

The marginal densities d1, d2 and CDFs p1, p2 must be differentiable for automatic differentiation (AD) to work.

Available copula constructors are:

  • cgaussian (Gaussian copula)

  • cclayton (Clayton copula)

  • cgumbel (Gumbel copula)

  • cfrank (Frank copula)

Value

Joint density (or log-density) under the bivariate copula.

See Also

ddcopula(), dmvcopula()

Examples

# Normal + Exponential margins with Gaussian copula
x <- c(0.5, 1); y <- c(1, 2)
d1 <- dnorm(x, 1, log = TRUE); d2 <- dexp(y, 2, log = TRUE)
p1 <- pnorm(x, 1); p2 <- pexp(y, 2)
dcopula(d1, d2, p1, p2, copula = cgaussian(0.5), log = TRUE)

# Normal + Beta margins with Clayton copula
x <- c(0.5, 1); y <- c(0.2, 0.8)
d1 <- dnorm(x, 1, log = TRUE); d2 <- dbeta(y, 2, 1, log = TRUE)
p1 <- pnorm(x, 1); p2 <- pbeta(y, 2, 1)
dcopula(d1, d2, p1, p2, copula = cclayton(2), log = TRUE)

# Normal + Beta margins with Gumbel copula
x <- c(0.5, 1); y <- c(0.2, 0.4)
d1 <- dnorm(x, 1, log = TRUE); d2 <- dbeta(y, 2, 1, log = TRUE)
p1 <- pnorm(x, 1); p2 <- pbeta(y, 2, 1)
dcopula(d1, d2, p1, p2, copula = cgumbel(1.5), log = TRUE)

# Normal + Exponential margins with Frank copula
x <- c(0.5, 1); y <- c(1, 2)
d1 <- dnorm(x, 1, log = TRUE); d2 <- dexp(y, 2, log = TRUE)
p1 <- pnorm(x, 1); p2 <- pexp(y, 2)
dcopula(d1, d2, p1, p2, copula = cfrank(2), log = TRUE)

RTMBdist documentation built on April 1, 2026, 5:07 p.m.