Learn R Programming

splineCox (version 0.0.8)

spline.copula.simu: Random generation from the B-spline copula using five M-spline basis functions

Description

spline.copula.simu generates random samples \((U, V)\) from the B-spline copula defined by a 5×5 coefficient matrix R. The simulation uses the inverse transform method based on the conditional distribution \(V \mid U=u\).

Usage

spline.copula.simu(
  n,
  R = "PE1",
  seed = NULL,
  report_tau = TRUE,
  report_rho = TRUE,
  verbose = FALSE
)

Value

A list containing:

  • U: simulated U-values;

  • V: simulated V-values;

  • R: user-specified R (preset name or matrix).

If report_tau = TRUE, the list also returns:

  • tau_emp: empirical Kendall's tau;

  • tau_theory: theoretical Kendall's tau.

If report_rho = TRUE, the list also returns:

  • rho_emp: empirical Spearman's rho;

  • rho_theory: theoretical Spearman's rho.

Arguments

n

Integer. Number of samples to generate.

R

A 5×5 non-negative coefficient matrix or a preset name: "PE1", "PE2", "PE3", "PN1", "PN2", "PN3", "I", "NE1", "NE2", "NE3", "NN1", "NN2", "NN3".

seed

Optional integer for reproducibility.

report_tau

Logical. If TRUE, returns empirical and theoretical Kendall's tau.

report_rho

Logical. If TRUE, returns empirical and theoretical Spearman's rho.

verbose

Logical. If TRUE, prints correlation results.

Details

Given \(U \sim \mathrm{Uniform}(0,1)\), the conditional distribution function of \(V \mid U = u\) is $$F_{V\mid U=u}(v) = M(u)^\top R I(v),$$ where \(M(\cdot)\) and \(I(\cdot)\) are the five M-spline and I-spline basis vectors. For each \(u\), a draw \(V\) is obtained by solving \(F_{V\mid U=u}(v)=W\) for \(v\), where \(W\sim U(0,1)\).

If report_tau = TRUE, the function also returns:

  • tau_emp: empirical Kendall's tau of the simulated values;

  • tau_theory: theoretical Kendall's tau computed using spline.copula with Kendall = TRUE.

If report_rho = TRUE, the function also returns:

  • rho_emp: empirical Spearman's rho of the simulated values;

  • rho_theory: theoretical Spearman's rho computed using spline.copula with Spearman = TRUE.

Examples

Run this code
set.seed(123)
out <- spline.copula.simu(2000, R = "PE1",
                          report_tau = TRUE,
                          report_rho = TRUE)
out$tau_emp
out$tau_theory
out$rho_emp
out$rho_theory

Run the code above in your browser using DataLab