| N.test | R Documentation | 
Performs tests based on the (weighted) number of records, 
N^\omega. The hypothesis of the classical record model (i.e., of IID
continuous RVs) is tested against the alternative hypothesis.
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
)
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   | 
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:
N^\omega = \sum_{m=1}^M \sum_{t=1}^T \omega_t I_{tm},
where \omega_t are weights given to the different records
according to their position in the series and I_{tm} are the record
indicators (see I.record).
The statistic N^\omega is exact Poisson binomial distributed
when the \omega_t's only take values in \{0,1\}. In any case,
it is also approximately normally distributed, with
Z = \frac{N^\omega - \mu}{\sigma},
where its mean and variance are
\mu = M \sum_{t=1}^T \omega_t \frac{1}{t},
\sigma^2 = M \sum_{t=2}^T \omega_t^2 \frac{1}{t} \left(1-\frac{1}{t}\right).
If correct = TRUE, then a continuity correction will be employed:
Z = \frac{N^\omega \pm 0.5 - \mu}{\sigma},
with “-” if the alternative is greater and “+” if the 
alternative is less.
When M>1, the expression of the variance under the null hypothesis
can be substituted by the sample variance in the M series, 
\hat{\sigma}^2. In this case, the statistic N_{S}^\omega
is asymptotically t 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 T and M.
Some comments and a power study are given by Cebrián, Castillo-Mateo and
Asín (2022).
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.  | 
Jorge Castillo-Mateo
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. \Sexpr[results=rd]{tools:::Rd_expr_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. \Sexpr[results=rd]{tools:::Rd_expr_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. \Sexpr[results=rd]{tools:::Rd_expr_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. \Sexpr[results=rd]{tools:::Rd_expr_doi("10.1016/j.csda.2012.10.006")}.
N.record, N.plot, 
foster.test, foster.plot,
brown.method
# 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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.