Computes the p-value of the statistic by computing its rank compared to its simulated values.
pvalue(S0, S, type = c("geq","leq","absolute","two-tailed"))
Arguments
S0: An atomic vector. Value of the test statistic applied to the data.
S: A vector. It consists of replications of the test statistic. S must have length greater than one.
type: A character string. It specifies the type of test the p-value function produces. The possible values are geq, leq, absolute and two-tailed. Default is geq.
Returns
The p-value of the statistic S0 given a vector of replications S.
Details
We allow for four types of p-value: leq, geq, absolute and two-tailed. For one-tailed test, leq returns the proportion of simulated values smaller than the statistic while geq returns the proportion of simulated values greater than the statistic. For two-tailed test with a symmetric satistic, one can use the absolute value of the statistic and its simulated values to retrieve a two-tailed test (i.e. type = absolute). If the statistic is not symmetric, one can specify the p-value type as two-tailed which is equivalent to twice the minimum of leq and geq.
Ties in the ranking are broken according to a uniform distribution.
Examples
# Generate sample S0 and simulate statisticsS0 =0S = rnorm(99)# Compute p-valuepvalue(S0, S, type ="geq")
References
Dufour, J.-M. (2006), Monte Carlo Tests with nuisance parameters: A general approach to finite sample inference and nonstandard asymptotics in econometrics. Journal of Econometrics, 133(2) , 443-447.
Dufour, J.-M. and Khalaf L. (2003), Monte Carlo Test Methods in Econometrics. in Badi H. Baltagi, ed., A Companion to Theoretical Econometrics, Blackwell Publishing Ltd, 494-519.