spline.copula {splineCox}R Documentation

B-spline copula using the five M-spline basis functions

Description

spline.copula computes the B-spline copula (or its density) based on the five-parameter M-spline basis functions. This copula is a specific instance of the B-spline copula family, and can be implemented using matrix-based operations with M.spline and I.spline from the joint.Cox package.

Usage

spline.copula(
  u,
  v,
  R = "PE1",
  mat = FALSE,
  density = FALSE,
  Kendall = FALSE,
  Spearman = FALSE
)

Arguments

u

A numeric vector of values in [0, 1] (uniform marginals for the first variable).

v

A numeric vector of values in [0, 1] (uniform marginals for the second variable).

R

A 5×5 non-negative coefficient matrix defining the copula structure. The matrix must satisfy the following conditions:

  • All entries must be non-negative (R_{kl} \ge 0).

  • The sum of all entries must be exactly 1.

  • The row sums and column sums must equal: c(1/8, 1/4, 1/4, 1/4, 1/8) (in order).

These conditions ensure that the resulting function is a valid copula density. You may also specify one of the built-in presets: "PE1", "PE2",–"PE3", "PN1", "PN2", "PN3", "I", NE1", "NE2", "NE3", "NN1", "NN2", "NN3". Default '"PE1"'.

mat

Logical; if TRUE, returns the full matrix (outer product) of copula evaluations; otherwise returns only the diagonal values, i.e., C(u_i, v_i) or c(u_i, v_i) for i = 1,...,n. Default is FALSE.

density

Logical; if TRUE, evaluates the copula density; if FALSE, evaluates the copula function. Default is FALSE.

Kendall

Logical; if TRUE, returns Kendall’s tau in addition to copula values. Default is FALSE.

Spearman

Logical; if TRUE, returns Spearman’s rho in addition to copula values. Default is FALSE.

Details

If density = TRUE, the function computes the copula **density** \(c(u, v)\); otherwise, it returns the **copula distribution function** \(C(u, v)\). If density = FALSE, it returns the copula function. The implementation uses five M-spline or I-spline basis functions defined on [0,1]. The coefficient matrix is fixed internally but can be modified in advanced use.

Value

If both Kendall = FALSE and Spearman = FALSE (default), returns:

If Kendall = TRUE or Spearman = TRUE, returns a list containing:

See Also

M.spline, I.spline

Examples

# Example data
library(joint.Cox)
library(ggplot2)

# Example data
library(joint.Cox)
library(ggplot2)

N = 50
u = v = seq(from = 0, to = 1, length.out = N)
U = rep(u, N)
V = rep(v, each = N)

c.data = data.frame(U = U, V = V, C = spline.copula(U, V, R = "PE1", density=TRUE))
ggplot(aes(x = U, y = V), data = c.data) +
  geom_contour(aes(x = U, y = V, z = C, colour = after_stat(level)),
  data = c.data, bins=25) + xlab("u") + ylab("v")


[Package splineCox version 0.0.5 Index]