p.plot {RecordTest} | R Documentation |
Probabilities of Record Plots
Description
This function builds a ggplot object to display different
functions of the record probabilities at time ,
.
A graphical tool to study the hypothesis of the classical record model
(i.e., of IID continuous RVs).
Usage
p.plot(
X,
plot = c("1", "2", "3"),
record = c(FU = 1, FL = 1, BU = 1, BL = 1),
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",
smooth = TRUE,
smooth.formula = y ~ x,
smooth.method = stats::lm,
smooth.weight = TRUE,
smooth.linetype = c(FU = 1, FL = 1, BU = 2, BL = 2),
...
)
Arguments
X |
A numeric vector, matrix (or data frame). |
plot |
One of the values "1", "2" or "3" (character or numeric class are both allowed). It determines the type of plot to be displayed (see Details). |
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. |
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
|
smooth |
(If |
smooth.formula |
( |
smooth.method |
(If |
smooth.weight |
(If |
smooth.linetype |
(If |
... |
Further arguments to pass through the smooth
(see |
Details
Three different types of plots which aim to analyse the hypothesis
of the classical record model using the record probabilities are
implemented. Estimations of the record probabilities used
in the plots are obtained as the proportion of records at time
in
vectors (columns of matrix
X
) (see
p.record
).
Type 1 is the plot of the observed values versus time
(see
p.regression.test
for its associated test and
details).
The expected values under the classical record model are for any
value
, so that a cloud of points around
and with no trend
should be expected. The estimated values are plotted, together with
binomial reference intervals (RIs). In addition, a smoothing function
can be fitted to the cloud of points.
Type 2 is the plot of the estimated record probabilities versus
time
. The expected probabilities under the classical record model,
, are also plotted, together with binomial RIs.
Type 3 is the same plot but on a logarithmic scale, so that the
expected value is . In this case, another smoothing
function can be fitted to the cloud of points.
Type 1 plot was proposed by Cebrián, Castillo-Mateo, Asín (2022), while type 2 and 3 appear in Benestad (2003, Figures 8 and 9, 2004, Figure 4).
Value
A ggplot object.
Author(s)
Jorge Castillo-Mateo
References
Benestad RE (2003). “How Often Can We Expect a Record Event?” Climate Research, 25(1), 3-13. doi:10.3354/cr025003.
Benestad RE (2004). “Record-Values, Nonstationarity Tests and Extreme Value Distributions.” Global and Planetary Change, 44(1-4), 11–26. doi:10.1016/j.gloplacha.2004.06.002.
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
Examples
# three plots available
p.plot(ZaragozaSeries, plot = 1)
p.plot(ZaragozaSeries, plot = 2)
p.plot(ZaragozaSeries, plot = 3)
# Posible fits (plot 1):
#fit a line
p.plot(ZaragozaSeries, record = c(1,0,0,0))
# fit a second order polynomial
p.plot(ZaragozaSeries, record = c(1,0,0,0),
smooth.formula = y ~ poly(x, degree = 2))
# force the line to pass by E(t*p_t) = 1 when t = 1, i.e., E(t*p_t) = 1 + beta_1 * (t-1)
p.plot(ZaragozaSeries, record = c(1,0,0,0),
smooth.formula = y ~ I(x-1) - 1 + offset(rep(1, length(x))))
# force the second order polynomial pass by E(t*p_t) = 1 when t = 1
p.plot(ZaragozaSeries, record = c(1,0,0,0),
smooth.formula = y ~ I(x-1) + I(x^2-1) - 1 + offset(rep(1, length(x))))
# fit a loess
p.plot(ZaragozaSeries, record = c(1,0,0,0),
smooth.method = stats::loess, span = 0.25)