Learn R Programming

RecordTest (version 2.2.0)

p.chisq.test: Pearson's Chi-Square Test for Probabilities of Record

Description

This function performs a chi-square goodness-of-fit test based on the record probabiliteis \(p_t\) to study the hypothesis of the classical record model (i.e., of IID continuous RVs).

Usage

p.chisq.test(
  X,
  record = c("upper", "lower"),
  simulate.p.value = FALSE,
  B = 1000
)

Value

A "htest" object with elements:

statistic

Value of the chi-squared statistic.

df

Degrees of freedom.

p.value

P-value.

method

A character string indicating the type of test performed.

data.name

A character string giving the name of the data.

Arguments

X

A numeric vector, matrix (or data frame).

record

A character string indicating the type of record to be calculated, "upper" or "lower".

simulate.p.value

Logical. Indicates whether to compute p-values by Monte Carlo simulation. It is recommended if the function returns a warning (see Details).

B

If simulate.p.value = TRUE, an integer specifying the number of replicates used in the Monte Carlo estimation.

Author

Jorge Castillo-Mateo

Details

The null hypothesis of this chi-square test is that in every vector (columns of the matrix X), the probability of record at time \(t\) is \(1/t\) as in the classical record model, and the alternative that the probabilities are not equal to those values. First, the chi-square goodness-of-fit statistics to study the null hypothesis \(H_0:\,p_t = 1/t\) are calculated for each time \(t=2,\ldots,T\), where the observed value is the number of records at time \(t\) in the \(M\) vectors and the expected value under the null is \(M / t\). The test statistic is the sum of the previous \(T-1\) statistics and its distribution under the null is approximately \(\chi^2_{T-1}\).

The chi-square approximation may not be valid with low \(M\), since it requires expected values \(> 5\) or up to \(20\%\) of the expected values are between 1 and 5. If this condition is not satisfied, a warning is displayed. In order to avoid this problem, a simulate.p.value can be made by means of Monte Carlo simulations.

References

Benestad RE (2003). “How Often Can We Expect a Record Event?” Climate Research, 25(1), 3-13. tools:::Rd_expr_doi("10.3354/cr025003").

Benestad RE (2004). “Record-Values, Nonstationarity Tests and Extreme Value Distributions.” Global and Planetary Change, 44(1-4), 11–26. tools:::Rd_expr_doi("10.1016/j.gloplacha.2004.06.002").

See Also

global.test, score.test, p.record, p.regression.test, lr.test

Examples

Run this code
# Warning, M = 76 small for the value of T = 70
p.chisq.test(ZaragozaSeries)
# Simulate p-value
p.chisq.test(ZaragozaSeries, simulate.p.value = TRUE, B = 10000)

Run the code above in your browser using DataLab