Learn R Programming

copula (version 0.999-7)

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

Description

gnacopula() conducts a goodness-of-fit test for the given ($H_0$-)copula cop based on the (copula-)data u.

Usage

gnacopula(u, cop, n.bootstrap,
          estim.method = eval(formals(enacopula)$method),
          include.K=TRUE, n.MC=0, trafo=c("Hering.Hofert", "Rosenblatt"),
          method=eval(formals(gofTstat)$method), verbose=TRUE, ...)

Arguments

u
$n\times d$-matrix of values in $[0,1]$; should be (pseudo-/copula-)observations from the copula to be tested. Consider applying the function pobs() first in order to obtain u.
cop
$H_0$-"outer_nacopula" with specified parameters to be tested for (currently only Archimedean copulas are provided).
n.bootstrap
positive integer specifying the number of bootstrap replicates.
estim.method
character string determining the estimation method; see enacopula(). We currently only recommend the default "mle" (or maybe
include.K
logical indicating whether the last component, involving the Kendall distribution function K(), is used in the transformation htrafo() of Hering and Hofert
n.MC
parameter n.MC for htrafo() (and thus for K()) if trafo="Hering.Hofert" and for rtrafo()<
trafo
a character string specifying the multivariate transformation performed for goodness-of-fit testing, which has to be one (or a unique abbreviation) of [object Object],[object Object]
method
a character string specifying the goodness-of-fit test statistic to be used; see gofTstat().
verbose
if TRUE, the progress of the bootstrap is displayed via txtProgressBar.
...
additional arguments passed to enacopula().

Value

  • gnacopula returns an Robject of class "htest". This object contains a list with the bootstrap results including the components [object Object],[object Object],[object Object],[object Object],[object Object],[object Object]

Details

The function gnacopula() performs a parametric bootstrap for the goodness-of-fit test specified by trafo and method. The transformation given by trafo specifies the multivariate transformation which is first applied to the (copula-) data u (typically, the pseudo-observations are used); see htrafo() or rtrafo() for more details. The argument method specifies the particular goodness-of-fit test carried out, which is either the Anderson-Darling test for the univariate standard uniform distribution (for method="AnChisq" or method="AnGamma") in a one-dimensional setup or the tests described in Genest et al. (2009) for the multivariate standard uniform distribution directly in a multivariate setup. As estimation method, the method provided by estim.method is used.

Note that a finite-sample correction is made when computing p-values; see gofCopula() for details.

A word of warning: Do work carefully with the variety of different goodness-of-fit tests that can be performed with gnacopula(). For example, among the possible estimation methods at hand, only MLE is known to be consistent (under conditions to be verified). Furthermore, for the tests based on the Anderson-Darling test statistic, it is theoretically not clear whether the parametric bootstrap converges. Consequently, the results obtained should be treated with care. Moreover, several estimation methods are known to be prone to numerical errors (see Hofert et al. (2011a)) and are thus not recommended to be used in the parametric bootstrap. A warning is given if gnacopula() is called with a method not being MLE.

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

gofTstat() for the implemented test statistis, gtrafo() for the multivariate transformation(s) htrafo() and rtrafo() involved and K() for the Kendall distribution function.

gofCopula() for other (parametric bootstrap) based goodness-of-fit tests.

Examples

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

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

## check if the data comes from a meta-Gumbel model (choose larger n.bootstrap
## in a realistic setup)
res.H0.G <- gnacopula(u, cop=copG, n.bootstrap=10)
## => uses the transformation of Hering and Hofert (2011), including
##    the Kendall distribution function K and the mapping to a univariate
##    setting via the chi-square distribution. The final test carried out
##    is the Anderson-Darling test.
res.H0.G$p.value # non-rejection according to 5\% level

## plot of the transformed data (Rosenblatt (1952))
uR <- rtrafo(u, cop=copG) # exact
pairs(uR, cex=0.2, gap=.2) # looks good

## plot of the transformed data (Hering and Hofert (2011))
uH <- htrafo(u, cop=copG)
pairs(uH, cex=0.2, gap=.2) # looks good

##' QQ-plot of the supposedly U[0,1] distributed variates
qq1dtrafo <- function(uh, ur) {
    require(lattice)
    d.z <- data.frame(z = c(
                      pchisq(rowSums(qnorm(uh)^2), d), ## Chi^2 -> U[0,1]
                      pgamma(rowSums(-log(uh)), shape=d), ## Gamma -> U[0,1]
                      pchisq(rowSums(qnorm(ur)^2), d),    ## Chi^2 -> U[0,1]
                      pgamma(rowSums(-log(ur)), shape=d)), ## Gamma -> U[0,1]
                      method = rep(c("H.chi2", "H.gam", "R.chi2",
                                     "R.gam"), each=n))
    qqmath(~ z | method, data = d.z, distribution = qunif,
           aspect = "xy", prepanel = prepanel.qqmathline,
           panel = function(x, ...) {
               panel.qqmathline(x, ...)
               panel.qqmath(x, ...)
           })
}
qq1dtrafo(uH, uR)

## what about a meta-Clayton model? (choose larger n.bootstrap in a
## realistic setup)
## note: the parameter of the Clayton copula is only a dummy,
##       it will be estimated anyway
copC <- onacopulaL("Clayton", list(1, 1:d))
res.H0.C <- gnacopula(u, cop=copC, n.bootstrap=10,
	              estim.method="mle")
res.H0.C$p.value # rejection according to 5\% level

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

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

## plot the supposedly U[0,1] distributed variates
qq1dtrafo(uH, uR)
## clearly not uniform (as expected)

Run the code above in your browser using DataLab