Title: | Estimation and Goodness-of-Fit of Copula-Based Models with Arbitrary Distributions |
---|---|
Description: | Estimation and goodness-of-fit functions for copula-based models of bivariate data with arbitrary distributions (discrete, continuous, mixture of both types). The copula families considered here are the Gaussian, Student, Clayton, Frank, Gumbel, Joe, Plackett, BB1, BB6, BB7,BB8, together with the following non-central squared copula families in Nasri (2020) <doi:10.1016/j.spl.2020.108704>: ncs-gaussian, ncs-clayton, ncs-gumbel, ncs-frank, ncs-joe, and ncs-plackett. For theoretical details, see, e.g., Nasri and Remillard (2023) <arXiv:2301.13408>. |
Authors: | Bouchra R. Nasri [aut, cre, cph], Bruno N Remillard [aut] |
Maintainer: | Bouchra R. Nasri <[email protected]> |
License: | GPL-3 |
Version: | 0.5.0 |
Built: | 2025-02-05 03:40:33 UTC |
Source: | https://github.com/cran/CopulaInference |
This function computes the empirical margins, their left-limits, Kendall's tau and Spearman's rho for arbitrary data. Slower than AuxFunC based on C.
AuxFun(data)
AuxFun(data)
data |
Matrix (x,y) of size n x 2 |
tau |
Kendall's tau |
rho |
Spearman's rho |
Fx |
Empirical cdf of x |
Fxm |
Left-limit of the empiricial cdf of x |
Fy |
Empirical cdf of y |
Fym |
Left-limit of the empiricial cdf of y |
Nasri (2022). Test of serial dependence for arbitrary distributions. JMVA
Nasri & Remillard (2023). Tests of independence and randomness for arbitrary data using copula-based covariances, arXiv 2301.07267.
data(simgumbel) out=AuxFun(simgumbel)
data(simgumbel) out=AuxFun(simgumbel)
This function computes the empirical margins, their left-limits, Kendall's tau and Spearman's rho for arbitrary data
AuxFunC(data)
AuxFunC(data)
data |
Matrix (x,y) of size n x 2 |
tau |
Kendall's tau |
rho |
Spearman's rho |
Fx |
Empirical cdf of x |
Fxm |
Left-limit of the empirical cdf of x |
Fy |
Empirical cdf of y |
Fym |
Left-limit of the empirical cdf of y |
Nasri (2022). Test of serial dependence for arbitrary distributions. JMVA
Nasri & Remillard (2023). Tests of independence and randomness for arbitrary data using copula-based covariances, arXiv 2301.07267.
data(simgumbel) out=AuxFunC(simgumbel)
data(simgumbel) out=AuxFunC(simgumbel)
This function computes the empirical joint cdf evaluated at all points (y1,y2)
BiEmpCdf(data, y1, y2)
BiEmpCdf(data, y1, y2)
data |
Matrix (x1,x2) of size n x 2 |
y1 |
Vector of size n1 |
y2 |
Vector of size n2 |
cdf |
Empirical cdf |
data(simgumbel) out=BiEmpCdf(simgumbel,c(0,1),c(-1,0,1))
data(simgumbel) out=BiEmpCdf(simgumbel,c(0,1),c(-1,0,1))
This function computes the inverse of the cdf of a finite distribution for a vector of probabilities.
CdfInv(u, y, Fn)
CdfInv(u, y, Fn)
u |
Vector of probabilities |
y |
Ordered values |
Fn |
Cdf |
x |
Vector of quantiles |
y=c(0,1,2) Fn = c(0.5,0.85,1) out=CdfInv(c(1:9)/10,y,Fn)
y=c(0,1,2) Fn = c(0.5,0.85,1) out=CdfInv(c(1:9)/10,y,Fn)
This function computes the density of the non-central squared copula (ncs) associated with a one-parameter copula with parameter cpar, and parameters a1, a2 >0 .
dncs(data, family, rotation = 0, par)
dncs(data, family, rotation = 0, par)
data |
Matrix (x,y) of size n x 2 |
family |
Copula family: "ncs-gaussian", "ncs-clayton", "ncs-frank", "ncs-gumbel", "ncs-joe", "ncs-plackett”. |
rotation |
Rotation: 0 (default value), 90, 180, or 270. |
par |
vector of copula parameter and non-centrality parameter a1,a2 >0 |
pdf |
Density |
Nasri (2020). On non-central squared copulas. Statistics and Probability Letters.
dncs(c(0.5,0.8),"ncs-clayton",par=c(2,1,2))
dncs(c(0.5,0.8),"ncs-clayton",par=c(2,1,2))
This function computes the density of the Plackett copula with parameter par>0.
dplac(data, rotation = 0, par)
dplac(data, rotation = 0, par)
data |
Matrix (x,y) of size n x 2 |
rotation |
Rotation: 0 (default value), 90, 180, or 270. |
par |
Copula parameter >0 |
pdf |
Density |
dplac(c(0.5,0.8),par=3,rotation=270)
dplac(c(0.5,0.8),par=3,rotation=270)
This function computes the empirical cdf evaluated at all sample points
EmpCdf(x)
EmpCdf(x)
x |
Observations |
Fx |
Empirical cdf |
Fxm |
Left limit of the empirical cdf |
Ix |
Indicator of atoms |
data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABIAAAASCAYAAABWzo5XAAAAWElEQVR42mNgGPTAxsZmJsVqQApgmGw1yApwKcQiT7phRBuCzzCSDSHGMKINIeDNmWQlA2IigKJwIssQkHdINgxfmBBtGDEBS3KCxBc7pMQgMYE5c/AXPwAwSX4lV3pTWwAAAABJRU5ErkJggg==
data(simgumbel) out=EmpCdf(simgumbel[,1])
data(simgumbel) out=EmpCdf(simgumbel[,1])
Sets starting values, upper and lower bounds for the parameters. The bounds are based on those in the rvinecopulib package.
est_options(family, tau = 0.5)
est_options(family, tau = 0.5)
family |
Copula family: "gaussian", "t", "clayton", "frank", "gumbel", "joe", "plackett”, "bb1", "bb6", "bb7","bb8","ncs-gaussian", "ncs-clayton", "ncs-gumbel", "ncs-frank", "ncs-joe","ncs-plackett". |
tau |
Estimated Kendall's tau to compute a starting point (default is 0.5) |
LB |
Lower bound for the parameters |
UB |
Upper bound for the parameters |
start |
Starting point for the estimation |
Nagler & Vatter (2002). rvinecopulib: High Performance Algorithms for Vine Copula Modeling. Version 0.6.2.1.3
Nasri (2020). On non-central squared copulas. Statistics and Probability Letters.
Nasri (2022). Test of serial dependence for arbitrary distributions. JMVA.
Nasri & Remillard (2023). Copula-based dependence measures for arbitrary data, arXiv 2301.07267.
out = est_options("bb8")
out = est_options("bb8")
Computes the estimation of the parameters of a copula-based model with arbitrary distributions, i.e, possibly mixtures of discrete and continuous distributions. Parametric margins are allowed. The estimation is based on a pseudo-likelihood adapted to ties.
EstBiCop( data = NULL, family, rotation = 0, Fx = NULL, Fxm = NULL, Fy = NULL, Fym = NULL )
EstBiCop( data = NULL, family, rotation = 0, Fx = NULL, Fxm = NULL, Fy = NULL, Fym = NULL )
data |
Matrix or data frame with 2 columns (X,Y). Can be pseudo-observations. If NULL, Fx and Fy must be provided. |
family |
Copula family: "gaussian", "t", "clayton", "frank", "gumbel", "joe", "plackett”, "bb1", "bb6", "bb7","bb8","ncs-gaussian", "ncs-clayton", "ncs-gumbel", "ncs-frank", "ncs-joe","ncs-plackett". |
rotation |
Rotation: 0 (default value), 90, 180, or 270. |
Fx |
Marginal cdf function applied to X (default is NULL). |
Fxm |
Left-limit of marginal cdf function applied to X default is NULL). |
Fy |
Marginal cdf function applied to Y (default is NULL). |
Fym |
Left-limit of marginal cdf function applied to Y (default is NULL). |
par |
Copula parameters |
family |
Copula family |
rotation |
Rotation value |
tauth |
Kendall's tau corresponding to the estimated parameter |
tauemp |
Empirical Kendall's tau (from the multilinear empirical copula) |
rhoSth |
Spearman's rho corresponding to the estimated parameter |
rhoSemp |
Empirical Spearman's tau (from the multilinear empirical copula) |
loglik |
Log-likelihood |
aic |
Aic value |
bic |
Bic value |
data |
Matrix of values (could be (Fx,Fy)) |
F1 |
Cdf of X (Fx if provided, empirical otherwise) |
F1m |
Left-limit of F1 (Fxm if provided, empirical otherwise) |
F2 |
Cdf of Y (Fy if provided, empirical otherwise) |
F2m |
Left-limit of F2 (Fym if provided, empirical otherwise) |
ccdfx |
Conditional cdf of X given Y and it left limit |
ccdfxm |
Left-limit of ccdfx |
ccdfy |
Conditional cdf of Y given X and it left limit |
ccdfym |
Left-limit of ccdfy |
Nasri & Remillard (2023). Identifiability and inference for copula-based semiparametric models for random vectors with arbitrary marginal distributions. arXiv 2301.13408.
Nasri (2020). On non-central squared copulas. Statistics and Probability Letters.
set.seed(2) data = matrix(rpois(20,1),ncol=2) out0=EstBiCop(data,"gumbel")
set.seed(2) data = matrix(rpois(20,1),ncol=2) out0=EstBiCop(data,"gumbel")
This function computes Kendall's tau and Spearman's rho for arbitrary data. These are invariant by increasing mappings.
EstDep(data)
EstDep(data)
data |
Matrix or data frame with 2 columns (X,Y). Can be pseudo-observations. |
tau |
Kendall's tau |
rho |
Spearman's rho |
Nasri (2022). Test of serial dependence for arbitrary distributions. JMVA
Nasri & Remillard (2023). Tests of independence and randomness for arbitrary data using copula-based covariances, arXiv 2301.07267.
data(simgumbel) out=EstDep(simgumbel)
data(simgumbel) out=EstDep(simgumbel)
This function computes the quantile of seven cdf used in Nasri (2022).
Finv(u, k)
Finv(u, k)
u |
Vector of probabilities |
k |
Marginal distribution: [1] Bernoulli(0.8), [2] Poisson(6), [3] Negative binomial with r = 1.5, p = 0.2, [4] Zero-inflated Poisson (10) with w = 0.1 and P(6.67) otherwise, [5] Zero-inflated Gaussian, [6] Discretized Gaussian, [7] Discrete Pareto(1) |
x |
Vector of quantiles |
Bouchra R. Nasri January 2021
B.R Nasri (2022). Tests of serial dependence for arbitrary distributions
x = Finv(runif(40),2)
x = Finv(runif(40),2)
Computes the number associated with a copula family (without rotation)
fnumber(family)
fnumber(family)
family |
Copula family: "gaussian", "t", "clayton", "frank", "gumbel", "joe", "plackett”, "bb1", "bb6", "bb7","bb8". |
fnumber |
Number |
Nagler et al. (2023). VineCopula: Statistical Inference of Vine Copulas, version 2.4.5.
fnumber("bb1")
fnumber("bb1")
Goodness-of-fit tests for copula-based models for data with arbitrary distributions. The tests statistics are the Cramer-von Mises statistic (Sn), the difference between the empirical Kendall's tau and the theoretical one, and the difference between the empirical Spearman's rho and the theoretical one.
GofBiCop( data = NULL, family, rotation = 0, Fx = NULL, Fxm = NULL, Fy = NULL, Fym = NULL, B = 100, n_cores = 1 )
GofBiCop( data = NULL, family, rotation = 0, Fx = NULL, Fxm = NULL, Fy = NULL, Fym = NULL, B = 100, n_cores = 1 )
data |
Matrix or data frame with 2 columns (X,Y). Can be pseudo-observations. If NULL, Fx and Fy must be provided. |
family |
Copula family: "gaussian", "t", "clayton", "frank", "gumbel", "joe", "plackett”, "bb1", "bb6", "bb7","bb8","ncs-gaussian", "ncs-clayton", "ncs-gumbel", "ncs-frank", "ncs-joe","ncs-plackett". |
rotation |
Rotation: 0 (default value), 90, 180, or 270. |
Fx |
marginal cdf function applied to X (default is NULL). |
Fxm |
left limit of marginal cdf function applied to X default is NULL). |
Fy |
marginal cdf function applied to Y (default is NULL). |
Fym |
left limit of marginal cdf function applied to Y (default is NULL). |
B |
Number of bootstrap samples (default 100) |
n_cores |
Number of cores to be used for parallel computing (default is 1). |
pvalueSn |
Pvalue of Sn in percent |
pvalueTn |
Pvalue of Tn in percent |
pvalueRn |
Pvalue of Rn in percent |
Sn |
Value of Cramer-von Mises statistic Sn |
Tn |
Value of Kendall's statistic Tn |
Rn |
Value of Spearman's statistic Rn |
cpar |
Copula parameters |
family |
Copula family |
rotation |
Rotation value |
tauth |
Kendall's tau (from the multilinear theoretical copula) |
tauemp |
Empirical Kendall's tau (from the multilinear empirical copula) |
rhoth |
Spearman's rho (from the multilinear theoretical copula) |
rhoemp |
Empirical Spearman's rho (from the multilinear empirical copula) |
parB |
Bootstrapped parameters |
loglik |
Log-likelihood |
aic |
AIC value |
bic |
BIC value |
Nasri & Remillard (2023). Identifiability and inference for copula-based semiparametric models for random vectors with arbitrary marginal distributions. arXiv 2301.13408.
Nasri & Remillard (2023). Goodness-of-fit and bootstrapping for copula-based random vectors with arbitrary marginal distributions.
Nasri (2020). On non-central squared copulas. Statistics and Probability Letters.
data = rvinecopulib::rbicop(10,"gumbel",rotation=0,2) out=GofBiCop(data,family="gumbel",B=10)
data = rvinecopulib::rbicop(10,"gumbel",rotation=0,2) out=GofBiCop(data,family="gumbel",B=10)
This function computes the conditional distribution of the non-central squared copula (ncs) associated with a one-parameter copula with parameter cpar, and parameters a1, a2 >0 .
hncs(data, cond_var, family, rotation = 0, par)
hncs(data, cond_var, family, rotation = 0, par)
data |
Matrix (x,y) of size n x 2 |
cond_var |
Conditioning variable (1 or 2) |
family |
Copula family: "ncs-gaussian", "ncs-clayton", "ncs-frank", "ncs-gumbel", "ncs-joe", "ncs-plackett”. |
rotation |
Rotation: 0 (default value), 90, 180, or 270. |
par |
vector of copula parameter and non-centrality parameter a1,a2 >0 |
h |
Conditional cdf |
Nasri (2020). On non-central squared copulas. Statistics and Probability Letters.
hncs(c(0.5,0.8),1,"ncs-clayton",270,c(2,1,2))
hncs(c(0.5,0.8),1,"ncs-clayton",270,c(2,1,2))
This function computes the conditional distribution of the Plackett copula with parameter par>0.
hplac(data, cond_var, rotation = 0, par)
hplac(data, cond_var, rotation = 0, par)
data |
Matrix (x,y) of size n x 2 |
cond_var |
Conditioning variable (1 or 2) |
rotation |
Rotation: 0 (default value), 90, 180, or 270. |
par |
Copula parameter >0 |
h |
Conditional cdf |
hplac(c(0.5,0.8),1,270,3)
hplac(c(0.5,0.8),1,270,3)
Determines if a copula family is identifiable with respect to the empirical margins. One-parameter copula families ("gaussian","gumbel","clayton","frank","plackett","joe") are identifiable whatever the margins. The rank of the gradient of the copula on the range of the margins is evaluated at 10000 parameter points within the lower and upper bounds of the copula family.
identifiability(data = NULL, family, rotation = 0, Fx = NULL, Fy = NULL)
identifiability(data = NULL, family, rotation = 0, Fx = NULL, Fy = NULL)
data |
Matrix or data frame with 2 columns (X,Y). Can be pseudo-observations. If NULL, Fx and Fy must be provided. |
family |
Copula family: "gaussian", "t", "clayton", "frank", "gumbel", "joe", "plackett”, "bb1", "bb6", "bb7","bb8","ncs-gaussian", "ncs-clayton", "ncs-gumbel", "ncs-frank", "ncs-joe","ncs-plackett". |
rotation |
Rotation: 0 (default value), 90, 180, or 270. |
Fx |
Marginal cdf function applied to X (default is NULL). |
Fy |
Marginal cdf function applied to Y (default is NULL). |
out |
True or False |
Nasri & Remillard (2023). Identifiability and inference for copula-based semiparametric models for random vectors with arbitrary marginal distributions. arXiv 2301.13408.
Nasri (2020). On non-central squared copulas. Statistics and Probability Letters.
set.seed(1) data = matrix(rpois(20,1),ncol=2) out = identifiability(data,"gumbel")
set.seed(1) data = matrix(rpois(20,1),ncol=2) out = identifiability(data,"gumbel")
This function computes the distribution function of the non-central squared copula (ncs) associated a with one-parameter copula with parameter cpar, and parameters a1, a2 >0 .
pncs(data, family, rotation = 0, par)
pncs(data, family, rotation = 0, par)
data |
Matrix (x,y) of size n x 2 |
family |
Copula family: "ncs-gaussian", "ncs-clayton", "ncs-frank", "ncs-gumbel", "ncs-joe", "ncs-plackett”. |
rotation |
Rotation: 0 (default value), 90, 180, or 270. |
par |
vector of copula parameter and non-centrality parameter a1,a2 >0 |
cdf |
Value of cdf |
Nasri (2020). On non-central squared copulas. Statistics and Probability Letters.
pncs(c(0.5,0.8),"ncs-clayton", par=c(2,1,2),rotation=270)
pncs(c(0.5,0.8),"ncs-clayton", par=c(2,1,2),rotation=270)
This function computes the distribution function of the Plackett copula with parameter par>0.
pplac(data, rotation = 0, par)
pplac(data, rotation = 0, par)
data |
Matrix (x,y) of size n x 2 |
rotation |
Rotation: 0 (default value), 90, 180, or 270. |
par |
Copula parameter >0 |
cdf |
Value of cdf |
pplac(c(0.5,0.8),270,3)
pplac(c(0.5,0.8),270,3)
This function computes the unique values, cdf and pdf for a series of data.
preparedata(x)
preparedata(x)
x |
Vector |
values |
Unique (sorted) values |
m |
Number of unique values |
Fn |
Empirical cdf of the unique values |
fn |
Empirical pdf of the unique values |
B.R. Nasri (2022). Tests of serial dependence for arbitrary distributions
C. Genest, J.G. Neslehova, B.N. Remillard and O. Murphy (2019). Testing for independence in arbitrary distributions.
#'@examples x = c(0,0,0,2,3,1,3,1,2,0) out = prepare_data(x)
Computes the theoretical Spearman's rho for Plackett copula
rhoplackett(cpar, rotation = 0)
rhoplackett(cpar, rotation = 0)
cpar |
Copula parameter; can be a vector. |
rotation |
Rotation: 0 (default value), 90, 180, or 270. |
rho |
Spearman's rho |
Remillard (2013). Statistical Methods for Financial Engineering. CRC Press
rhoplackett(3,rotation=90)
rhoplackett(3,rotation=90)
This function computes generates a bivariate sample from a non-central squared copula (ncs) associated with a one-parameter copula with parameter cpar, and parameters a1, a2 >0 .
rncs(n, family, rotation = 0, par)
rncs(n, family, rotation = 0, par)
n |
Number of observations |
family |
Copula family: "ncs-gaussian", "ncs-clayton", "ncs-frank", "ncs-gumbel", "ncs-joe", "ncs-plackett”. |
rotation |
Rotation: 0 (default value), 90, 180, or 270. |
par |
vector of copula parameter and non-centrality parameter a1,a2 >0 |
U |
Observations |
Nasri (2020). On non-central squared copulas. Statistics and Probability Letters.
rncs(100,"ncs-clayton",par=c(2,1,2))
rncs(100,"ncs-clayton",par=c(2,1,2))
This function generates observations from a Plackett copula with parameter par>0.
rplac(n, rotation = 0, par)
rplac(n, rotation = 0, par)
n |
Number of pairs to be generated |
rotation |
Rotation: 0 (default value), 90, 180, or 270. |
par |
Copula parameter >0 |
U |
Matrix of observations |
rplac(10,rotation=90,par=2)
rplac(10,rotation=90,par=2)
Simulated data from a Gumbel copula with parameter 2, Bernoulli margin for X1 and zero-inflated Gaussian margin for X2.
data(simgumbel)
data(simgumbel)
Data frame of numerical values
data(simgumbel) plot(simgumbel,xlab="X1", ylab="X2")
data(simgumbel) plot(simgumbel,xlab="X1", ylab="X2")
Computation of goodness-of-fit statistics (Cramer-von Mises and the Kendall's tau)
statcvm(object)
statcvm(object)
object |
Object of class 'EstBiCop'. |
Sn |
Cramer-von Mises statistic |
Tn |
Kendall's statistic |
Rn |
Spearman's statistic |
tauemp |
Empirical Kendall's tau |
tauth |
Kendall's tau of the multilineat theoretical copula |
rhoemp |
Empirical Spearman's rho |
rhoth |
Spearman's rho of the multilineat theoretical copula |
Y1 |
Ordered observed values of X1 |
F1 |
Empirical cdf of Y1 |
Y2 |
Ordered observed values of X2 |
F2 |
Empirical cdf of Y2 |
cpar |
Copula parameters |
family |
Copula family |
rotation |
Rotation value |
n |
Sample size |
Nasri & Remillard (2023). Identifiability and inference for copula-based semiparametric models for random vectors with arbitrary marginal distributions. arXiv 2301.13408.
set.seed(2) data = matrix(rpois(20,1),ncol=2) out0 = EstBiCop(data,"gumbel") out = statcvm(out0)
set.seed(2) data = matrix(rpois(20,1),ncol=2) out0 = EstBiCop(data,"gumbel") out = statcvm(out0)
This function computes Kendall's tau for a copula family
taucop(family_number, cpar, rotation = 0)
taucop(family_number, cpar, rotation = 0)
family_number |
Integer from 1 to 10 |
cpar |
Copula parameters |
rotation |
Rotation: 0 (default value), 90, 180, or 270. |
tau |
Kendall's tau |
taucop(4,2,270) # Gumbel copula
taucop(4,2,270) # Gumbel copula
This function computes Kendall's tau for Plackett family using numerical integration
tauplackett(cpar, rotation = 0)
tauplackett(cpar, rotation = 0)
cpar |
Copula parameter >0 |
rotation |
Rotation: 0 (default value), 90, 180, or 270. |
tau |
Kendall's tau |
tauplackett(2,270)
tauplackett(2,270)