Learn R Programming

copula (version 0.999-7)

gtrafo: Goodness-of-fit Testing Transformations for (Nested) Archimedean Copulas

Description

htrafo() the transformation described in Hering and Hofert (2011).

rtrafo() the transformation of Rosenblatt (1952).

Usage

htrafo(u, cop, include.K=TRUE, n.MC=0, inverse=FALSE,
       method=formals(qK)$method, u.grid, ...)
rtrafo(u, cop, j.ind = 2:d, m, n.MC=0, log=FALSE, trafo.only=log)

Arguments

u
$n\times d$-matrix of (pseudo-/copula-)observations (each value in $[0,1]$) from the copula cop based on which the transformation is carried out. Consider applying the function pobs fi
cop
the "outer_nacopula" with specified parameters based on which the transformation is computed (currently only Archimedean copulas are provided).
include.K
logical indicating whether the last component, involving the Kendall distribution function K, is used in htrafo.
j.ind
integer vector of indices $j$ between 2 and $d$ indicating the conditional distributions that are to be computed.
m
(deprecated, use j.ind instead). Now, j.ind = 2:M should be used instead of m=M.
n.MC
parameter n.MC for K (for htrafo) or for approximating the derivatives involved (for rtrafo).
inverse
logical indicating whether the inverse of the transformation is returned.
method
method to compute qK.
u.grid
argument of qK (for method="discrete").
...
additional arguments passed to qK.
log
logical specifying if the logarithm of the transformation, i.e., conditional distribution is desired (for the j.ind indices; i.e., u[,1] is returned unchanged also in this case).
trafo.only
logical; if true, only the transformed part is returned, i.e., the unchanged first column is not. This is typically useful when log = TRUE or when the conditional distribution is only needed for certain indices (j.ind

Value

  • htrafo() returns an $n\times d$- or $n\times (d-1)$-matrix (depending on whether include.K is TRUE or FALSE) containing the transformed input u.

    rtrafo() returns an $n\times d$-matrix containing the transformed input u.

Details

[object Object],[object Object]

References

Genest, C., Ré{e}millard, B., and Beaudoin, D. (2009), Goodness-of-fit tests for copulas: A review and a power study Insurance: Mathematics and Economics 44, 199--213.

Rosenblatt, M. (1952), Remarks on a Multivariate Transformation, The Annals of Mathematical Statistics 23, 3, 470--472.

Hering, C. and Hofert, M. (2011), Goodness-of-fit tests for Archimedean copulas in large dimensions, submitted.

Hofert, M., Mächler{Maechler}, M., and McNeil, A. J. (2012). Likelihood inference for Archimedean copulas in high dimensions under known margins. Journal of Multivariate Analysis 110, 133--150.

See Also

gnacopula where both transformations are applied or emde where htrafo is applied.

Examples

Run this code
tau <- 0.5
(theta <- copGumbel@iTau(tau)) # 2
(copG <- onacopulaL("Gumbel", list(theta, 1:5))) # d = 5

set.seed(1)
n <- 1000
x <- rnacopula(n, copG)
x <- qnorm(x) # x now follows a meta-Gumbel model with N(0,1) marginals
u <- pobs(x) # build pseudo-observations

## graphically check if the data comes from a meta-Gumbel model
## with the transformation of Hering and Hofert (2011):
u.h <- htrafo(u, cop=copG) # transform the data
pairs(u.h, cex=0.2) # looks good

## with the transformation of Rosenblatt (1952):
u.r <- rtrafo(u, cop=copG) # transform the data
pairs(u.r, cex=0.2) # looks good

## what about a meta-Clayton model?
## the parameter is chosen such that Kendall's tau equals (the same) tau
copC <- onacopulaL("Clayton", list(copClayton@iTau(tau), 1:5))

## plot of the transformed data (Hering and Hofert (2011)) to see the
## deviations from uniformity
u.H <- htrafo(u, cop=copC) # transform the data
pairs(u.H, cex=0.2) # clearly visible

## plot of the transformed data (Rosenblatt (1952)) to see the
## deviations from uniformity
u.R <- rtrafo(u, cop=copC) # transform the data
pairs(u.R, cex=0.2) # clearly visible

## rtrafo() for elliptical:
fN <- fitCopula(normalCopula(dim=ncol(u)), u)
pairs(rtrafo(u, cop= fN@copula), cex = 0.2)# not so clearly visible
if(copula:::doExtras()) {
  f.t <- fitCopula(tCopula(dim=ncol(u)), u)
  tCop <- f.t@copula
} else {
  tCop <- tCopula(param = 0.685, df = 7, dim=ncol(u))
}
u.Rt <- rtrafo(u, cop= tCop)
pairs(u.Rt, cex = 0.2)# *not* clearly visible
stopifnot(all.equal(log(u.R[,-1]),
		    rtrafo(u, cop=copC, log=TRUE), tol=1e-14),
	  all.equal(log(rtrafo(u, cop= fN@copula, trafo.only=TRUE)),
		    rtrafo(u, cop= fN@copula, log=TRUE), tol=1e-14),
	  all.equal(log(u.Rt[,-1]),
		    rtrafo(u, cop= tCop, log=TRUE), tol=1e-14),
	  TRUE)

Run the code above in your browser using DataLab