N.test {RecordTest} | R Documentation |
Number of Records Test
Description
Performs tests based on the (weighted) number of records,
. The hypothesis of the classical record model (i.e., of IID
continuous RVs) is tested against the alternative hypothesis.
Usage
N.test(
X,
weights = function(t) 1,
record = c("upper", "lower"),
distribution = c("normal", "t", "poisson-binomial"),
alternative = c("greater", "less"),
correct = TRUE,
method = c("mixed", "dft", "butler"),
permutation.test = FALSE,
simulate.p.value = FALSE,
B = 1000
)
Arguments
X |
A numeric vector, matrix (or data frame). |
weights |
A function indicating the weight given to the different
records according to their position in the series,
e.g., if |
record |
A character string indicating the type of record to be
calculated, |
distribution |
A character string indicating the asymptotic
distribution of the statistic, |
alternative |
A character string indicating the type of alternative
hypothesis, |
correct |
Logical. Indicates, whether a continuity correction
should be done; defaults to |
method |
(If |
permutation.test |
Logical. Indicates whether to compute p-values by
permutation simulation (Castillo-Mateo et al. 2023). It does not require
that the columns of |
simulate.p.value |
Logical. Indicates whether to compute p-values by
Monte Carlo simulation. If |
B |
If |
Details
The null hypothesis is that the data come from a population with independent and identically distributed continuous realisations. The one-sided alternative hypothesis is that the (weighted) number of records is greater (or less) than under the null hypothesis. The (weighted)-number-of-records statistic is calculated according to:
where are weights given to the different records
according to their position in the series and
are the record
indicators (see
I.record
).
The statistic is exact Poisson binomial distributed
when the
's only take values in
. In any case,
it is also approximately normally distributed, with
where its mean and variance are
If correct = TRUE
, then a continuity correction will be employed:
with “” if the alternative is greater and “
” if the
alternative is less.
When , the expression of the variance under the null hypothesis
can be substituted by the sample variance in the
series,
. In this case, the statistic
is asymptotically
distributed, which is a more robust alternative
against serial correlation.
If permutation.test = TRUE
, the p-value is estimated by permutation
simulations. This is the only method of calculating p-values that does not
require that the columns of X
be independent.
If simulate.p.value = TRUE
, the p-value is estimated by Monte Carlo
simulations.
The size of the tests is adequate for any values of and
.
Some comments and a power study are given by Cebrián, Castillo-Mateo and
Asín (2022).
Value
A "htest"
object with elements:
statistic |
Value of the test statistic. |
parameter |
(If |
p.value |
P-value. |
alternative |
The alternative hypothesis. |
estimate |
(If |
method |
A character string indicating the type of test performed. |
data.name |
A character string giving the name of the data. |
Author(s)
Jorge Castillo-Mateo
References
Butler K, Stephens MA (2017). “The Distribution of a Sum of Independent Binomial Random Variables.” Methodology and Computing in Applied Probability, 19(2), 557-571. doi:10.1007/s11009-016-9533-4.
Castillo-Mateo J, Cebrián AC, Asín J (2023). “Statistical Analysis of Extreme and Record-Breaking Daily Maximum Temperatures in Peninsular Spain during 1960–2021.” Atmospheric Research, 293, 106934. doi:10.1016/j.atmosres.2023.106934.
Cebrián AC, Castillo-Mateo J, Asín J (2022). “Record Tests to Detect Non Stationarity in the Tails with an Application to Climate Change.” Stochastic Environmental Research and Risk Assessment, 36(2): 313-330. doi:10.1007/s00477-021-02122-w.
Hong Y (2013). “On Computing the Distribution Function for the Poisson Binomial Distribution.” Computational Statistics & Data Analysis, 59(1), 41-51. doi:10.1016/j.csda.2012.10.006.
See Also
N.record
, N.plot
,
foster.test
, foster.plot
,
brown.method
Examples
# Forward Upper records
N.test(ZaragozaSeries)
# Forward Lower records
N.test(ZaragozaSeries, record = "lower", alternative = "less")
# Forward Upper records
N.test(series_rev(ZaragozaSeries), alternative = "less")
# Forward Upper records
N.test(series_rev(ZaragozaSeries), record = "lower")
# Exact test
N.test(ZaragozaSeries, distribution = "poisson-binom")
# Exact test for records in the last decade
N.test(ZaragozaSeries, weights = function(t) ifelse(t < 61, 0, 1), distribution = "poisson-binom")
# Linear weights for a more powerful test (without continuity correction)
N.test(ZaragozaSeries, weights = function(t) t - 1, correct = FALSE)