Learn R Programming

gofCopula (version 0.1-2)

gofSn: The Sn gof test using the empirical copula

Description

gofSn 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. gofSn performs the "Sn" gof test, described in Genest et al. (2009), for copulae and compares the empirical copula against a parametric estimate of the copula derived under the null hypothesis. It exist two methods to obtain the approximate p-values, parametric bootstrap and a fast multiplier approach. 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

gofSn(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", "gumbel" and "frank".
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, whereTRUE 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

With the pseudo observations $U_{ij}$ for $i = 1, \dots,n$, $j = 1, \dots,d$ and $\mathbf{u} \in [0,1]^d$ is the empirical copula given by $C_n(\mathbf{u}) = \frac{1}{n} \sum_{i = 1}^n \mathbf{I}(U_{i1} \leq u_1, \dots, U_{id} \leq u_d).$ It shall be tested the $H_0$ hypothesis: $$C \in \mathcal{C}_0$$ with $\mathcal{C}_0$ as the true class of copulae under $H_0$. The test statistic $T$ is then defined as $$T = n \int_{[0,1]^d} { C_n(\mathbf{u}) - C_{\theta_n}(\mathbf{u}) }^2 d C_n(\mathbf{u})$$ with $C_{\theta_n}(\mathbf{u})$ the estimation of $C$ under the $H_0$. 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

Rosenblatt, M. (1952). Remarks on a Multivariate Transformation. The Annals of Mathematical Statistics 23, 3, 470-472. Hering, C. and Hofert, M. (2014). Goodness-of-fit tests for Archimedean copulas in high dimensions. Innovations in Quantitative Risk Management. 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))

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

Run the code above in your browser using DataLab