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:
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 |
density |
Logical; if |
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:
A numeric vector of length
length(u)
ifmat = FALSE
.A numeric matrix of size
length(u)
xlength(v)
ifmat = TRUE
.
If Kendall = TRUE
or Spearman = TRUE
, returns a list containing:
-
value
: A numeric vector or matrix representing the evaluated copula function or copula density. -
Kendall_tau
: (Optional) Kendall’s tau, included only ifKendall = TRUE
. -
Spearman_rho
: (Optional) Spearman’s rho, included only ifSpearman = TRUE
.
See Also
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")