N.plot {RecordTest} | R Documentation |
Number of Records Plot
Description
This function builds a ggplot object to compare the sample
means of the (weighted) number of records in a vector up to time ,
, and the expected values
under the classical record model (i.e., of IID continuous RVs).
Usage
N.plot(
X,
weights = function(t) 1,
record = c(FU = 1, FL = 1, BU = 1, BL = 1),
backward = c("T", "t"),
point.col = c(FU = "red", FL = "blue", BU = "red", BL = "blue"),
point.shape = c(FU = 19, FL = 19, BU = 4, BL = 4),
conf.int = TRUE,
conf.level = 0.9,
conf.aes = c("ribbon", "errorbar"),
conf.col = "grey69"
)
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 |
Logical vector. Vector with four elements indicating if forward upper, forward lower, backward upper and backward lower are going to be shown, respectively. Logical values or 0,1 values are accepted. |
backward |
A character string |
point.col , point.shape |
Vector with four elements indicating the colour and shape of the points. Every one of the four elements represents forward upper, forward lower, backward upper and backward lower, respectively. |
conf.int |
Logical. Indicates if the RIs are also shown. |
conf.level |
(If |
conf.aes |
(If |
conf.col |
Colour used to plot the expected value and (if
|
Details
This plot is associated to the test N.test
.
It calculates the sample means of the number of records in a set of
vectors up to every time (see
Nmean.record
).
These sample means are calculated from the sample of
values obtained from
vectors, the columns of matrix
X
. Then, these values are plotted and compared with the expected
values and their reference intervals (RIs), under
the hypothesis of the classical record model. The RIs of
uses the fact that, under the classical record
model, the statistic is asymptotically Normal.
The plot can show the four types of record at the same time (i.e.,
forward upper, forward lower, backward upper and backward lower).
In their interpretations one must be careful, for forward records
each time corresponds to the same year of observation, but for
the backward series, time
corresponds to the year of observation
where
is the total number of observations in every
series. Two types of backward records can be considered (see argument
backward
).
More details of this plot are shown in Cebrián, Castillo-Mateo, Asín (2022).
Value
A ggplot object.
Author(s)
Jorge Castillo-Mateo
References
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.
See Also
N.record
, N.test
,
foster.test
, foster.plot
Examples
# Plot at Zaragoza, with linear weights and error bar as RIs aesthetic
N.plot(ZaragozaSeries, weights = function(t) t-1, conf.aes = "errorbar")
# Plot only upper records
N.plot(ZaragozaSeries, record = c(1, 0, 1, 0))
# Change point colour and shape
Zplot <- N.plot(ZaragozaSeries,
point.col = c("red", "red", "blue", "blue"),
point.shape = c(19, 4, 19, 4))
## Not run: Load package ggplot2 to change the plot
#library("ggplot2")
## Remove legend
#Zplot + ggplot2::theme(legend.position = "none")
## Fancy axis
# Zplot +
# ggplot2::scale_x_continuous(name = "Year (forward)",
# breaks = c(10, 30, 50, 70),
# labels=c("1960", "1980", "2000", "2020"),
# sec.axis = ggplot2::sec_axis(~ 2021 - ., name = "Year (backward)",
# breaks = 1950 + c(10, 30, 50, 70))) +
# ggplot2::theme(axis.title.x = ggplot2::element_text(colour = "red"),
# axis.text.x = ggplot2::element_text(colour = "red"),
# axis.title.x.top = ggplot2::element_text(colour = "blue"),
# axis.text.x.top = ggplot2::element_text(colour = "blue"))