# global_p: Compute global p-values In TOHM: Testing One Hypothesis Multiple Times

## Description

It computes the global p-value for a given value of the test statistic.

## Usage

 ```1 2``` ```global_p(c, ck, type = c("Gaussian", "Chi^2", "Chi-bar^2"), k = NULL, k_vec = NULL, weights = NULL, ECdensities = NULL, ECs) ```

## Arguments

 `c` Observed value of the test statistic. `ck` Vector of thresholds defining the excursions sets with respect to which the ECs are computed. `type` Type of random field. The possible options are `"Gaussian"`, `"Chi^2"`, and `"Chi-bar^2"`. See details. `k` If `type="Chi^2"`, degrees of freedom of the Chi-square random field. `k_vec` If `type="Chi-bar^2"` the degrees of freedom of the Chi-square random fields in the mixture. `weights` If `type="Chi-bar^2"` the weights of the mixure of Chi-square random fields in the mixture. The ordering should be the same as in `k_vec`. `ECdensities` See datails. `ECs` A vector or matrix containing the Euler characteristics (ECs) computed over a Monte Carlo simulation of the random field under the null model. Each colum correspond to the ECs obtained for each of the thresholds in `ck`.

## Details

If `type="Chi-bar^2"` the degrees of freedom of the Chi-square random fields involved in the mixture, as well as the respective weights, have to be spefcified in the arguments `k_vec` and `weights`. If the distribution of the random field is not available in `type`, the user can specify in `ECdensities` a function taking `c` as argument and returning the vector of the desired EC densities to be evaluated at `c`. Notice that the length of the vector returned by the function specified in `ECdensities` must corresponds to one plus the dimension of the search area (since the first value should correspond to the EC density of order zero (see `ECden_vec`)).

## Value

 `global_p ` Global p-value. `MCerror ` Monte Carlo error associated to the global p-vaue.

Sara Algeri

## References

S. Algeri and D.A. van Dyk. Testing one hypothesis multiple times: The multidimensional case. arXiv:1803.03858, submitted to the Journal of Computational and Graphical Statistics, 2018.

`find_max`,`TOHM_LRT`,`ECden_vec`
 ```1 2 3``` ```ck<-c(1,2) ECs<-cbind(rpois(100,1.5),rpois(100,1)) global_p(c=12,ck=ck,type="Gaussian",ECs=ECs) ```