gnacopula()
conducts a goodness-of-fit test for the given
($H_0$-)copula cop
based on the (copula-)data u
. gtrafouni()
transforms supposedly $\mathrm{U}[0,1]^d$
distributed vectors of random variates to univariate data (for testing in a
one-dimensional setup).
gnacopula(u, cop, n.bootstrap,
estimation.method = eval(formals(enacopula)$method),
include.K=TRUE, n.MC=0, trafo= c("Hering.Hofert", "Rosenblatt"),
method=eval(formals(gtrafouni)$method), verbose=TRUE, ...)
gtrafouni(u, method = c("chisq", "gamma", "Remillard", "Genest"))
pobs
first in order to obtain u
."outer_nacopula "
with specified
parameters to be tested for (currently only Archimedean copulas are
provided).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]character
string specifying the
goodness-of-fit method to be used, which has to be one (or a unique
abbreviation) of
[object Object],[object Object],[object Object],[object Object]TRUE
, the progress of the bootstrap is
displayed via txtProgressBar
.enacopula
.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] gtrafouni
returns a numeric vector of length $n$
(=nrow(u)
) containing the univariate transformed values.
gnacopula
performs a 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="chisq"
or
method="gamma"
) in a one-dimensional setup or the tests
described in Genest, Restimation.method
is used. 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 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 bootstrap. A warning is given if
gnacopula()
is called with a method not being MLE.
Since Ris widely used by practitioners, a word of warning concerning
goodness-of-fit tests in general is also advisable.
Goodness-of-fit tests are often (ab)used in practice to
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.,
gtrafo
for the multivariate transformation(s)
htrafo
and rtrafo
involved and
K
for the Kendall distribution function. gofCopula
for other (parametric bootstrap) based
GOF tests.
tau <- 0.5
(theta <- copGumbel@tauInv(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,
estimation.method="mle")
## => 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))
u.prime <- rtrafo(u, cop=copG) # exact
pairs(u.prime, cex=0.2) # looks good
## plot of the transformed data (Hering and Hofert (2011))
u.prime. <- htrafo(u, cop=copG)
pairs(u.prime., cex=0.2) # looks good
## 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,
estimation.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
u.prime <- htrafo(u, cop=copC) # transform the data
pairs(u.prime, cex=0.2) # clearly visible
## plot of the transformed data (Rosenblatt (1952)) to see the deviations from
## uniformity
u.prime. <- rtrafo(u, cop=copC) # transform the data
pairs(u.prime., cex=0.2) # clearly visible
## plot the supposedly U[0,1] distributed variates
z <- gtrafouni(u.prime)
plot(1:length(z), z)
## a bit harder to see, but not perfectly uniform (as expected)
Run the code above in your browser using DataLab