Learn R Programming

gofCopula (version 0.1-2)

gofADGamma: Gof test using the Anderson-Darling test statistic and the gamma distribution

Description

gofADGamma is a wrapper for the functions gofCopula, fitCopula, ellipCopula and archmCopula from the package copula. It combines these functions to test a dataset for a copula directly without all the necessary intermediate steps and extends its functionality. The margins can be estimated by a bunch of distributions and the time which is necessary for the estimation can be given. gofADGamma contains the ADGamma gof tests for copulae, described in Genest (2009) and Hofert (2014), and compares the empirical copula against a parametric estimate of the copula derived under the null hypothesis. The approximate p-values are computed with a parametric bootstrap. It is possible to insert datasets of all dimensions above 1 and the possible copulae are "gaussian", "t", "gumbel", "clayton" and "frank". The parameter estimation is performed with pseudo maximum likelihood method. In case the estimation fails, inversion of Kendall's tau is used.

Usage

gofADGamma(copula, x, M = 1000, param = 0.5, param.est = T, df = 4, df.est = T, 
            margins = "ranks", execute.times.comp = T)

Arguments

copula
The copula to test for. Possible are "gaussian", "t", "clayton" and "gumbel".
x
A matrix containing the residuals of the data.
M
Number of bootstrapping loops.
param
The copula parameter to use, if it shall not be estimated.
param.est
Shall be either TRUE or FALSE. TRUE means that param will be estimated.
df
Degrees of freedom, if not meant to be estimated. Only necessary if tested for "t"-copula.
df.est
Indicates if df shall be estimated. Has to be either FALSE or TRUE, where TRUE means that it will be estimated.
margins
Specifies which estimation method shall be used in case that the input data are not in the range [0,1]. The default is "ranks", which is the standard approach to convert data in such a case. Alternatively can the following distributions be sp
execute.times.comp
Logical. Defines if the time which the estimation most likely takes shall be computed. It'll be just given if M is at least 100.

Value

  • A object of the class gofCOP with the components
  • methoda character which informs about the performed analysis
  • erg.testsa matrix with the p-value and test statistic of test

Details

As written in Hofert et al. (2014) computes this Anderson-Darling test statistic for (supposedly) U[0,1]-distributed (under H_0) random variates via the distribution function of the gamma distribution. The $H_0$ hypothesis is $$C \in \mathcal{C}_0$$ with $\mathcal{C}_0$ as the true class of copulae under $H_0$. The Anderson-Darling test statistic of the variates $$G(x_i) = \Gamma_d \left( x_i \right)$$ is computed (via ADGofTest::ad.test), where $x_i = \sum_{j=1}^d (- \ln u_{ij})$, $\Gamma_d()$ denotes the distribution function of the gamma distribution with shape parameter d and shape parameter one (being equal to an Erlang(d) distribution function). The test statistic is then given by $$T = -n - \sum_{i=1}^n \frac{2i - 1}{n} [\ln(G(x_i)) + \ln(1 - G(x_{n+1-i}))].$$ The approximate p-value is computed by the formula, see copula, $$(0.5 + \sum_{b=1}^N \mathbf{I}(T_b \geq T) / (N+1),$$ where $T$ and $T_b$ denote the test statistic and the bootstrapped test statistc, respectively. This ensures that the approximate p-value is a number strictly between 0 and 1, which is sometimes necessary for further treatments. See Pesarin (2001) for more details.

References

Christian Genest, Bruno Remillard, David Beaudoin (2009). Goodness-of-fit tests for copulas: A review and a power study. Insurance: Mathematics and Economics, Volume 44, Issue 2, April 2009, Pages 199-213, ISSN 0167-6687. http://dx.doi.org/10.1016/j.insmatheco.2007.10.005 Marius Hofert, Ivan Kojadinovic, Martin Maechler, Jun Yan (2014). copula: Multivariate Dependence with Copulas. R package version 0.999-12.. http://CRAN.R-project.org/package=copula Pesarin, F. (2001). Multivariate Permutation Tests: With applications in Biostatistics, Wiley

Examples

Run this code
data = cbind(rnorm(100), rnorm(100), rnorm(100))

gofADGamma("gaussian", data, M = 20)

Run the code above in your browser using DataLab