Title: | Likelihood-Based Inference for Time Series Extremes |
---|---|
Description: | Performs likelihood-based inference for stationary time series extremes. The general approach follows Fawcett and Walshaw (2012) <doi:10.1002/env.2133>. Marginal extreme value inferences are adjusted for cluster dependence in the data using the methodology in Chandler and Bate (2007) <doi:10.1093/biomet/asm015>, producing an adjusted log-likelihood for the model parameters. A log-likelihood for the extremal index is produced using the K-gaps model of Suveges and Davison (2010) <doi:10.1214/09-AOAS292>. These log-likelihoods are combined to make inferences about extreme values. Both maximum likelihood and Bayesian approaches are available. |
Authors: | Paul J. Northrop [aut, cre, cph] |
Maintainer: | Paul J. Northrop <[email protected]> |
License: | GPL (>= 2) |
Version: | 1.1.1 |
Built: | 2025-01-13 03:33:32 UTC |
Source: | https://github.com/paulnorthrop/lite |
Performs likelihood-Based inference for stationary time series extremes. The general approach follows Fawcett and Walshaw (2012). Marginal extreme value inferences are adjusted for cluster dependence in the data using the methodology in Chandler and Bate (2007), producing an adjusted log-likelihood for the model parameters. A log-likelihood for the extremal index is produced using the K-gaps model of Suveges and Davison (2010). These log-likelihoods are combined to make inferences about return levels.
The main functions are flite
and blite
,
which perform frequentist and Bayesian inference for time series extremes,
respectively.
See the vignettes
vignette("lite-1-frequentist", package = "lite")
and vignette("lite-2-bayesian", package = "lite")
for an overview of the package.
Maintainer: Paul J. Northrop [email protected] [copyright holder]
Chandler, R. E. and Bate, S. (2007). Inference for clustered. data using the independence loglikelihood. Biometrika, 94(1), 167-183. doi:10.1093/biomet/asm015
Fawcett, L. and Walshaw, D. (2012), Estimating return levels from serially dependent extremes. Environmetrics, 23, 272-283. doi:10.1002/env.2133
Suveges, M. and Davison, A. C. (2010) Model misspecification in peaks over threshold analysis, Annals of Applied Statistics, 4(1), 203-221. doi:10.1214/09-AOAS292
flite
for frequentist threshold-based inference for
time series extremes.
returnLevel
for frequentist threshold-based inference
for return levels.
blite
for Bayesian threshold-based inference for
time series extremes.
predict.blite
for predictive inference for the
largest value observed in years.
Functions involved in making inferences about the probability of success in a Bernoulli distribution using maximum likelihood estimation.
fitBernoulli(data) ## S3 method for class 'Bernoulli' coef(object, ...) ## S3 method for class 'Bernoulli' vcov(object, ...) ## S3 method for class 'Bernoulli' nobs(object, ...) ## S3 method for class 'Bernoulli' logLik(object, ...)
fitBernoulli(data) ## S3 method for class 'Bernoulli' coef(object, ...) ## S3 method for class 'Bernoulli' vcov(object, ...) ## S3 method for class 'Bernoulli' nobs(object, ...) ## S3 method for class 'Bernoulli' logLik(object, ...)
data |
A numeric vector of outcomes from Bernoulli trials: 0 for a
failure, 1 for a success. Alternatively, a logical vector with FALSE
for a failure and TRUE for a success. Missing values are removed using
|
object |
A fitted model object returned from |
... |
Further arguments. None are used currently. |
fitBernoulli
: fit a Bernoulli distribution using maximum likelihood
estimation, using an independence log-likelihood formed by
summing contributions from individual observations. No adjustment for
cluster dependence has been made in estimating the variance-covariance
matrix stored as component in vcov
in the returned object.
coef, vcov, nobs
and logLik
methods are provided.
fitBernoulli
returns an object of class "Bernoulli"
, a list
with components: maxLogLik
, mle
, nobs
, vcov
,
n0
, n1
, data
, obs_data
, where data
are
the input data and, obs_data
are the input data after any missing
values have been removed, using na.omit
and
n0
and n1
are, respectively, the number of failures and the
number of successes.
coef.Bernoulli
: a numeric vector of length 1 with name prob
.
The MLE of the probability of success.
vcov.Bernoulli
: a matrix with row
and column name
prob
. The estimated variance of the estimator of
the probability of success. No adjustment for cluster dependence has
been made.
nobs.Bernoulli
: a numeric vector of length 1 with name prob
.
The number of observations used to estimate the probability of success.
logLik.Bernoulli
: an object of class "logLik"
: a numeric
scalar with value equal to the maximised log-likelihood. The returned
object also has attributes nobs
, the numbers of observations used
in this model fit, and "df"
(degrees of freedom), which is equal
to the number of total number of parameters estimated (1).
# Set up data cdata <- c(exdex::cheeseboro) u <- 45 exc <- cdata > u # Fit a Bernoulli distribution fit <- fitBernoulli(exc) # Calculate the log-likelihood at the MLE res <- logLikVector(fit) # The logLik method sums the individual log-likelihood contributions. logLik(res) # nobs, coef, vcov, logLik methods for objects returned from fitBernoulli() nobs(fit) coef(fit) vcov(fit) logLik(fit)
# Set up data cdata <- c(exdex::cheeseboro) u <- 45 exc <- cdata > u # Fit a Bernoulli distribution fit <- fitBernoulli(exc) # Calculate the log-likelihood at the MLE res <- logLikVector(fit) # The logLik method sums the individual log-likelihood contributions. logLik(res) # nobs, coef, vcov, logLik methods for objects returned from fitBernoulli() nobs(fit) coef(fit) vcov(fit) logLik(fit)
Performs threshold-based Bayesian inference for 3 aspects of stationary time series extremes: the probability that the threshold is exceeded, the marginal distribution of threshold excesses and the extent of clustering of extremes, as summarised by the extremal index.
blite( data, u, cluster, k = 1, inc_cens = TRUE, ny, gp_prior = revdbayes::set_prior(prior = "mdi", model = "gp"), b_prior = revdbayes::set_bin_prior(prior = "jeffreys"), theta_prior_pars = c(1, 1), n = 1000, type = c("vertical", "none"), ... )
blite( data, u, cluster, k = 1, inc_cens = TRUE, ny, gp_prior = revdbayes::set_prior(prior = "mdi", model = "gp"), b_prior = revdbayes::set_bin_prior(prior = "jeffreys"), theta_prior_pars = c(1, 1), n = 1000, type = c("vertical", "none"), ... )
data |
A numeric vector or numeric matrix of raw data. If If |
u |
A numeric scalar. The extreme value threshold applied to the data.
See Details for information about choosing |
cluster |
This argument is used to set the argument If |
k , inc_cens
|
Arguments passed to |
ny |
A numeric scalar. The (mean) number of observations per year.
Setting this appropriately is important when making predictive inferences
using |
gp_prior |
A list to specify a prior distribution for the GP parameters
( |
b_prior |
A list to specify a prior distribution for the Bernoulli
parameter |
theta_prior_pars |
A numerical vector of length 2 containing the
respective values of the parameters |
n |
An integer scalar. The size of posterior sample required. |
type |
A character scalar. Either |
... |
Further arguments to be passed to the function
|
See flite
for details of the (adjusted) likelihoods
on which these Bayesian inferences are based.
The likelihood is based on a model for 3 independent aspects.
A Bernoulli(u) model
for whether a given observation exceeds the threshold
.
A generalised Pareto,
GP(u,
), model for the marginal distribution of threshold
excesses.
The -gaps model for the extremal index
.
The general approach follows Fawcett and Walshaw (2012).
The contributions to the likelihood for
u and
(
u,
)
are based on the vertically-adjusted likelihoods described in
flite
. This is an example of Bayesian inference using a
composite likelihood Ribatet et al (2012). Priors for
u
(
u,
)
and
are set using the arguments
gp_prior
,
b_prior
and theta_prior_pars
.
Currently, only priors where
u
(
u,
)
and
are independent a priori are allowed.
Two tuning parameters need to be chosen: a threshold and the
-gaps run parameter
. The
exdex
package has a function choose_uk
to inform this
choice.
Random samples are simulated from the posteriors for
u and
(
u,
)
(using
ru
) and (using
kgaps_post
).
An object of class c("blite", "lite", "chandwich")
.
This object is an n
matrix containing the
posterior samples, with column names
c("p[u]", "sigma[u]", "xi", "theta")
.
The object also has the attributes "Bernoulli"
, "gp"
,
"theta"
, which provide the fitted model objects returned from
adjust_loglik
(for "Bernoulli"
and
"gp"
) and kgaps
(for "theta"
).
The named input arguments are returned in a list as the attribute
inputs
. If ny
was not supplied then its value is NA
.
The call to blite
is provided in the attribute "call"
.
A call to flite
is used to create adjusted log-likelihoods
for u and
(
u,
).
The object returned from the call is provided as the attribute
"flite_object"
.
Objects inheriting from class "blite"
have coef
,
nobs
, plot
, summary
, vcov
and confint
methods. See bliteMethods
.
predict.blite
can be used to make predictive inferences about
the largest value to be observed in N years.
Fawcett, L. and Walshaw, D. (2012), Estimating return levels from serially dependent extremes. Environmetrics, 23, 272-283. doi:10.1002/env.2133
Ribatet, M., Cooley, D., & Davison, A. C. (2012). Bayesian inference from composite likelihoods, with an application to spatial extremes. Statistica Sinica, 22(2), 813-845.
bliteMethods
, including plotting the posterior
samples.
predict.blite
to make predictive inferences about
future extreme values.
flite
for frequentist threshold-based inference
for time series extremes.
choose_uk
to inform the choice of the
threshold and run parameter
.
### Cheeseboro wind gusts cdata <- exdex::cheeseboro # Each column of the matrix cdata corresponds to data from a different year # blite() sets cluster automatically to correspond to column (year) cpost <- blite(cdata, u = 45, k = 3) summary(cpost) ## Plots of posterior samples plot(cpost) ## Credible intervals confint(cpost)
### Cheeseboro wind gusts cdata <- exdex::cheeseboro # Each column of the matrix cdata corresponds to data from a different year # blite() sets cluster automatically to correspond to column (year) cpost <- blite(cdata, u = 45, k = 3) summary(cpost) ## Plots of posterior samples plot(cpost) ## Credible intervals confint(cpost)
"blite"
Methods for objects of class "blite"
returned from
blite
. confint.blite
is a misnomer: it returns
(equi-tailed) Bayesian credible intervals.
## S3 method for class 'blite' plot(x, which = c("all", "pu", "gp", "xi", "theta"), ...) ## S3 method for class 'blite' coef(object, fun, ...) ## S3 method for class 'blite' vcov(object, ...) ## S3 method for class 'blite' nobs(object, ...) ## S3 method for class 'blite' summary( object, short = TRUE, mean = TRUE, digits = max(3, getOption("digits") - 3L), ... ) ## S3 method for class 'summary.blite' print(x, ...) ## S3 method for class 'blite' confint(object, parm = "all", level = 0.95, ...)
## S3 method for class 'blite' plot(x, which = c("all", "pu", "gp", "xi", "theta"), ...) ## S3 method for class 'blite' coef(object, fun, ...) ## S3 method for class 'blite' vcov(object, ...) ## S3 method for class 'blite' nobs(object, ...) ## S3 method for class 'blite' summary( object, short = TRUE, mean = TRUE, digits = max(3, getOption("digits") - 3L), ... ) ## S3 method for class 'summary.blite' print(x, ...) ## S3 method for class 'blite' confint(object, parm = "all", level = 0.95, ...)
x |
An object inheriting from class |
which |
A character scalar indicating which plot(s) to produce.
If |
... |
For For For Otherwise |
object |
An object of class |
fun |
A summary function to be applied to each column of the simulated
values in |
short |
A logical scalar that determines the form of the output. See Details. |
mean |
A logical scalar. Determines the form of the output if
|
digits |
An integer. Passed to |
parm |
A character vector specifying the parameters for which
confidence intervals are required. The default, |
level |
The credible level required. A numeric scalar in (0, 1). |
For plot.blite
, if which = "all"
then 4 plots are produced.
Top left: histogram of the posterior sample for the threshold
exceedance probability
u.
Top right: scatter plot of posterior sample for the GP
parameters
(u,
).
The linear constraint
> -
u /
(n)
is drawn on the plot.
Bottom left: histogram of the posterior sample for the GP shape
parameter .
Bottom right: histogram of the posterior sample for the extremal
index .
plot.blite
: No return value, only the plot is produced.
coef.blite
: a numeric vector of length 4 with names
c("p[u]", "sigma[u]", "xi", "theta")
. The values of summary
statistics calculated using the function fun
.
vcov.blite
: a matrix with row and
column names
c("p[u]", "sigma[u]", "xi", "theta")
. An estimate
of the posterior covariance matrix, calculated using
cov
.
nobs.blite
: a numeric vector of length 3 with names
c("p[u]", "gp", "theta")
. The respective number of observations
used to infer u,
(
u,
) and
.
summary.blite
: an object containing the original function call and
a matrix of summaries of the posterior samples for each of the
parameters. If short = TRUE
then there are 2 columns, containing
either the sample posterior means and standard deviations
(mean = TRUE
) or the sample posterior medians and inter-quartile
ranges (mean = FALSE
). If short = FALSE
then there are 4
columns, with each column containing the usual 6-number summary produced
by summary
. The object is printed by
print.summary.blite
.
print.summary.blite
: the argument x
is returned, invisibly.
confint.blite
: a numeric matrix with 2 columns giving the lower and
upper credible limits for each parameter. These columns are labelled
as (1-level)/2
and 1-(1-level)/2
, expressed as a
percentage, by default 2.5%
and 97.5%
. The row names
are the names of the parameters supplied in parm
.
blite
to perform frequentist threshold-based
inference for time series extremes.
predict.blite
: for predictive inference for the
largest value observed in years.
estfun
methodFunctions to calculate contributions to the score vector from individual observations for a fitted model object.
## S3 method for class 'Bernoulli' estfun(x, ...) ## S3 method for class 'GP' estfun(x, eps = 1e-05, m = 3, ...)
## S3 method for class 'Bernoulli' estfun(x, ...) ## S3 method for class 'GP' estfun(x, eps = 1e-05, m = 3, ...)
x |
A fitted model object. |
... |
Further arguments. None are used for
|
eps , m
|
These control the estimation of the observed
information in |
An estfun
method is used by
meatCL
to calculate the
meat
in the sandwich covariance estimator on which
the log-likelihood adjustments in flite
are based.
Specifically, meatCL
is used to calculate
the argument V
passed to adjust_loglik
.
An matrix containing contributions
to the score function from
observations for each of the
parameters.
estfun.Bernoulli
: an matrix, where
is the sample size, the length of the input
data
to
fitBernoulli
. The column is named prob
.
estfun.GP
: an matrix, where
is the
sample size, the length of the input
data
to fitGP
.
The columns are named sigma[u]
and xi
.
Bernoulli
for maximum likelihood inference for the
Bernoulli distribution.
generalisedPareto
for maximum likelihood inference
for the generalised Pareto distribution.
library(sandwich) # estfun.Bernoulli bfit <- fitBernoulli(c(exdex::cheeseboro) > 45) head(estfun(bfit)) # estfun.generalisedPareto gpfit <- fitGP(c(exdex::cheeseboro), u = 45) head(estfun(gpfit))
library(sandwich) # estfun.Bernoulli bfit <- fitBernoulli(c(exdex::cheeseboro) > 45) head(estfun(bfit)) # estfun.generalisedPareto gpfit <- fitGP(c(exdex::cheeseboro), u = 45) head(estfun(gpfit))
Performs threshold-based frequentist inference for 3 aspects of stationary time series extremes: the probability that the threshold is exceeded, the marginal distribution of threshold excesses and the extent of clustering of extremes, as summarised by the extremal index.
flite(data, u, cluster, k = 1, inc_cens = TRUE, ny, ...)
flite(data, u, cluster, k = 1, inc_cens = TRUE, ny, ...)
data |
A numeric vector or numeric matrix of raw data. If If |
u |
A numeric scalar. The extreme value threshold applied to the data.
See Details for information about choosing |
cluster |
This argument is used to set the argument If |
k , inc_cens
|
Arguments passed to |
ny |
A numeric scalar. The (mean) number of observations per year.
Setting this appropriately is important when making inferences about
return levels, using |
... |
Further arguments to be passed to the function
|
There are 3 independent parts to the inference, all performed using maximum likelihood estimation.
A Bernoulli(u)
model for whether a given observation exceeds the threshold
.
A generalised Pareto,
GP(u,
), model for the marginal distribution of threshold
excesses.
The -gaps model for the extremal index
.
The general approach follows Fawcett and Walshaw (2012).
For parts 1 and 2, inferences based on a mis-specified independence
log-likelihood are adjusted to account for clustering in the data. Here,
we follow Chandler and Bate (2007) to estimate adjusted log-likelihood
functions for u
and for (
u,
), with the
argument
cluster
defining the clusters. This aspect of the
calculations is performed using the adjust_loglik
in the chandwich
package (Northrop and Chandler,
2021). The GP distribution initial fit of the GP distribution to threshold
excesses is performed using the grimshaw_gp_mle
function in the revdbayes
package
(Northrop, 2020).
In part 3, the methodology described in Suveges and Davison (2010) is
implemented using the exdex
package
(Northrop and Christodoulides, 2022).
Two tuning parameters need to be chosen: a threshold and the
-gaps run parameter
. The
exdex
package has a function choose_uk
to inform this
choice.
Each part of the inference produces a log-likelihood function (adjusted
for parts 1 and 2). These log-likelihoods are combined (summed) to form
a log-likelihood function for the parameter vector
(u,
u,
,
). Return levels are a function of these
parameters and therefore inferences for return levels can be based on
this log-likelihood.
An object of class c("flite", "lite", "chandwich")
.
This object is a function with 2 arguments:
pars
, a numeric vector of length 4 to supply the value of
the parameter vector
(u,
u,
,
),
type
, a character scalar specifying the type of
adjustment made to the independence log-likelihood in parts
1 and 2, one of "vertical"
, "none"
, "cholesky"
,
or "spectral"
. For details see Chandler and Bate (2007).
The default is "vertical"
for the reason given in
the description of the argument adj_type
in
plot.flite
.
The object also has the attributes "Bernoulli"
, "gp"
,
"theta"
, which provide the fitted model objects returned from
adjust_loglik
(for "Bernoulli"
and
"gp"
) and kgaps
(for "theta"
).
The named input arguments are returned in a list as the attribute
inputs
. If ny
was not supplied then its value is NA
.
The call to flite
is provided in the attribute "call"
.
Objects inheriting from class "flite"
have coef
,
logLik
, nobs
, plot
, summary
, vcov
and confint
methods. See fliteMethods
.
returnLevel
can be used to make frequentist inferences about
return levels.
Chandler, R. E. and Bate, S. (2007). Inference for clustered. data using the independence loglikelihood. Biometrika, 94(1), 167-183. doi:10.1093/biomet/asm015
Fawcett, L. and Walshaw, D. (2012), Estimating return levels from serially dependent extremes. Environmetrics, 23, 272-283. doi:10.1002/env.2133
Northrop, P. J. and Chandler, R. E. (2021). chandwich: Chandler-Bate Sandwich Loglikelihood Adjustment. R package version 1.1.5. https://CRAN.R-project.org/package=chandwich.
Northrop, P. J. and Christodoulides, C. (2022). exdex: Estimation of the Extremal Index. R package version 1.1.1. https://CRAN.R-project.org/package=exdex/.
Northrop, P. J. (2020). revdbayes: Ratio-of-Uniforms Sampling for Bayesian Extreme Value Analysis. R package version 1.3.9. https://paulnorthrop.github.io/revdbayes/
Suveges, M. and Davison, A. C. (2010) Model misspecification in peaks over threshold analysis, Annals of Applied Statistics, 4(1), 203-221. doi:10.1214/09-AOAS292
fliteMethods
, including plotting (adjusted)
log-likelihoods for
(u,
u,
,
).
returnLevel
to make frequentist inferences about
return levels.
blite
for Bayesian threshold-based inference
for time series extremes.
Bernoulli
for maximum likelihood inference for the
Bernoulli distribution.
generalisedPareto
for maximum likelihood inference
for the generalised Pareto distribution.
kgaps
for maximum likelihood inference from
the -gaps model for the extremal index.
choose_uk
to inform the choice of the
threshold and run parameter
.
### Cheeseboro wind gusts # Make inferences cdata <- exdex::cheeseboro # Each column of the matrix cdata corresponds to data from a different year # flite() sets cluster automatically to correspond to column (year) cfit <- flite(cdata, u = 45, k = 3) summary(cfit) # 2 ways to find the maximised log-likelihood value cfit(coef(cfit)) logLik(cfit) # Plots of (adjusted) log-likelihoods plot(cfit) plot(cfit, which = "gp") ## Confidence intervals # Based on an adjusted profile log-likelihood confint(cfit) # Symmetric intervals based on large sample normality confint(cfit, profile = FALSE)
### Cheeseboro wind gusts # Make inferences cdata <- exdex::cheeseboro # Each column of the matrix cdata corresponds to data from a different year # flite() sets cluster automatically to correspond to column (year) cfit <- flite(cdata, u = 45, k = 3) summary(cfit) # 2 ways to find the maximised log-likelihood value cfit(coef(cfit)) logLik(cfit) # Plots of (adjusted) log-likelihoods plot(cfit) plot(cfit, which = "gp") ## Confidence intervals # Based on an adjusted profile log-likelihood confint(cfit) # Symmetric intervals based on large sample normality confint(cfit, profile = FALSE)
"flite"
Methods for objects of class "flite"
returned from
flite
.
## S3 method for class 'flite' plot( x, which = c("all", "pu", "gp", "xi", "theta"), adj_type = c("vertical", "none", "cholesky", "spectral"), ... ) ## S3 method for class 'flite' coef(object, ...) ## S3 method for class 'flite' vcov(object, adjust = TRUE, ...) ## S3 method for class 'flite' nobs(object, ...) ## S3 method for class 'flite' logLik(object, ...) ## S3 method for class 'flite' summary(object, adjust = TRUE, digits = max(3, getOption("digits") - 3L), ...) ## S3 method for class 'summary.flite' print(x, ...) ## S3 method for class 'flite' confint( object, parm = "all", level = 0.95, adj_type = c("vertical", "none", "cholesky", "spectral"), profile = TRUE, ... )
## S3 method for class 'flite' plot( x, which = c("all", "pu", "gp", "xi", "theta"), adj_type = c("vertical", "none", "cholesky", "spectral"), ... ) ## S3 method for class 'flite' coef(object, ...) ## S3 method for class 'flite' vcov(object, adjust = TRUE, ...) ## S3 method for class 'flite' nobs(object, ...) ## S3 method for class 'flite' logLik(object, ...) ## S3 method for class 'flite' summary(object, adjust = TRUE, digits = max(3, getOption("digits") - 3L), ...) ## S3 method for class 'summary.flite' print(x, ...) ## S3 method for class 'flite' confint( object, parm = "all", level = 0.95, adj_type = c("vertical", "none", "cholesky", "spectral"), profile = TRUE, ... )
x |
An object inheriting from class |
which |
A character scalar indicating which plot(s) to produce.
If |
adj_type |
A character scalar passed to
|
... |
For For For Otherwise |
object |
An object of class |
adjust |
A logical scalar. If |
digits |
An integer. Passed to |
parm |
A character vector specifying the parameters for which
confidence intervals are required. The default, |
level |
The confidence level required. A numeric scalar in (0, 1). |
profile |
A logical scalar. If |
For plot.flite
, if which = "all"
then 4 plots are
produced.
Top left: (adjusted) log-likelihood for the threshold exceedence
probability u,
with a horizontal line indicating a 95% confidence interval for
u.
Top right: contour plot of the (adjusted) log-likelihood for the
GP parameters
(u,
),
showing (25, 50, 75, 90, 95)% confidence regions. The linear
constraint
> -
u /
(n) is drawn on
the plot.
Bottom left: (adjusted) log-likelihood for , with a
horizontal line indicating a 95% confidence interval for
.
Bottom right: log-likelihood for the extremal index
, with a horizontal line indicating a 95% confidence
interval for
.
plot.flite
: No return value, only the plot is produced.
coef.flite
: a numeric vector of length 4 with names
c("p[u]", "sigma[u]", "xi", "theta")
. The MLEs of the parameters
u,
u,
and
.
vcov.flite
: a matrix with row and
column names
c("p[u]", "sigma[u]", "xi", "theta")
. The estimated
variance-covariance matrix for the model parameters. If
adjust = TRUE
then the elements corresponding to
u,
u,
and
are adjusted for cluster dependence using
a sandwich estimator; otherwise they are not adjusted.
nobs.flite
: a numeric vector of length 3 with names
c("p[u]", "gp", "theta")
. The respective number of observations
used to estimate u,
(
u,
) and
.
logLik.flite
: an object of class "logLik"
: a numeric scalar
with value equal to the maximised log-likelihood. This is the sum of
contributions from three fitted models, from a Bernoulli model for
occurrences of threshold exceedances, a generalised Pareto model for
threshold excesses and a -gaps model for the extremal index.
The returned object also has attributes
nobs
, the numbers of
observations used in each of these model fits, and "df"
(degrees
of freedom), which is equal to the number of total number of parameters
estimated (4).
summary.flite
: an object containing the original function call and
a matrix of estimates and estimated standard errors with row names
c("p[u]", "sigma[u]", "xi", "theta")
. The object is printed by
print.summary.flite
.
print.summary.flite
: the argument x
is returned, invisibly.
confint.flite
: a numeric matrix with 2 columns giving the lower and
upper confidence limits for each parameter. These columns are labelled
as (1-level)/2
and 1-(1-level)/2
, expressed as a
percentage, by default 2.5%
and 97.5%
. The row names
are the names of the parameters supplied in parm
.
flite
to perform frequentist threshold-based
inference for time series extremes.
Functions involved in making inferences about the scale and shape parameters of a generalised Pareto distribution using maximum likelihood estimation.
fitGP(data, u) ## S3 method for class 'GP' coef(object, ...) ## S3 method for class 'GP' vcov(object, ...) ## S3 method for class 'GP' nobs(object, ...) ## S3 method for class 'GP' logLik(object, ...) gpObsInfo(pars, excesses, eps = 1e-05, m = 3)
fitGP(data, u) ## S3 method for class 'GP' coef(object, ...) ## S3 method for class 'GP' vcov(object, ...) ## S3 method for class 'GP' nobs(object, ...) ## S3 method for class 'GP' logLik(object, ...) gpObsInfo(pars, excesses, eps = 1e-05, m = 3)
data |
A numeric vector of raw data. Missing values are removed using
|
u |
A numeric scalar. The extremal value threshold. |
object |
A fitted model object returned from |
... |
Further arguments to be passed to the functions in the
sandwich package |
pars |
A numeric parameter vector of length 2 containing the values of the generalised Pareto scale and shape parameters. |
excesses |
A numeric vector of threshold excesses, that is, amounts
by which exceedances of |
eps , m
|
These control the estimation of the observed
information in |
fitGP
: fit a generalised Pareto distribution using maximum likelihood
estimation, using an independence log-likelihood formed by
summing contributions from individual observations. No adjustment for
cluster dependence has been made in estimating the variance-covariance
matrix stored as component in vcov
in the returned object. This
function calls grimshaw_gp_mle
.
coef
, vcov
, nobs
and logLik
methods are
provided for objects of class "GP"
returned from fitGP
.
gpObsInfo
: calculates the observed information matrix for a random
sample excesses
from the generalized Pareto distribution, that is,
the negated Hessian matrix of the generalized Pareto independence
log-likelihood, evaluated at pars
.
fitGP
returns an object of class "GP"
, a list
with components: maxLogLik
, threshold
, mle
,
vcov
, exceedances
, nexc
,
where exceedances
is a vector containing the values that exceed the
threshold threshold
and nexc
is the length of this vector.
coef.GP
: a numeric vector of length 2 with names
c("sigma[u]", "xi")
. The MLEs of the GP parameters
and
.
vcov.GP
: a matrix with row and
column names
c("sigma[u]", "xi")
. The estimated
variance-covariance matrix for the model parameters. No adjustment for
cluster dependence has been made.
nobs.GP
: a numeric vector of length 1. The number of
observations used to estimate (,
).
logLik.GP
: an object of class "logLik"
: a numeric scalar
with value equal to the maximised log-likelihood. The returned object
also has attributes nobs
, the numbers of observations used in
each of these model fits, and "df"
(degrees of freedom), which is
equal to the number of total number of parameters estimated (2).
gpObsInfo
returns a 2 by 2 matrix with row and columns names
c("sigma[u]", "xi")
.
# Set up data and set a threshold cdata <- c(exdex::cheeseboro) # Fit a generalised Pareto distribution fit <- fitGP(cdata, 45) # Calculate the log-likelihood at the MLE res <- logLikVector(fit) # The logLik method sums the individual log-likelihood contributions. logLik(res) # nobs, coef, vcov, logLik methods for objects returned from fitGP() nobs(fit) coef(fit) vcov(fit) logLik(fit)
# Set up data and set a threshold cdata <- c(exdex::cheeseboro) # Fit a generalised Pareto distribution fit <- fitGP(cdata, 45) # Calculate the log-likelihood at the MLE res <- logLikVector(fit) # The logLik method sums the individual log-likelihood contributions. logLik(res) # nobs, coef, vcov, logLik methods for objects returned from fitGP() nobs(fit) coef(fit) vcov(fit) logLik(fit)
Generic function for calculating log-likelihood contributions from individual observations for a fitted model object.
logLikVector(object, ...) ## S3 method for class 'Bernoulli' logLikVector(object, pars = NULL, ...) ## S3 method for class 'GP' logLikVector(object, pars = NULL, ...) ## S3 method for class 'logLikVector' logLik(object, ...)
logLikVector(object, ...) ## S3 method for class 'Bernoulli' logLikVector(object, pars = NULL, ...) ## S3 method for class 'GP' logLikVector(object, pars = NULL, ...) ## S3 method for class 'logLikVector' logLik(object, ...)
object |
A fitted model object. |
... |
Further arguments. None are used for either
|
pars |
A numeric parameter vector. For For |
A logLikVector
method is used to construct a log-likelihood
function to supply as the argument loglik
to the function
adjust_loglik
, which performs log-likelihood
adjustment for parts 1 and 2 of the inferences performed by
flite
.
The logLik
method logLik.LogLikVector
sums the
log-likelihood contributions from individual observations.
For logLikVector
: an object of class logLikVec
.
This is a numeric vector of length containing contributions to the
the independence log-likelihood from
observations, with attributes
"df"
(degrees of freedom), giving the number of estimated
parameters in the model, and "nobs"
, giving the number observations
used to perform the estimation.
For logLik.logLikVector
: an object of class logLik
. This is
a number with the attributes "df"
and "nobs"
as described
above.
Bernoulli
for maximum likelihood inference for the
Bernoulli distribution.
generalisedPareto
for maximum likelihood inference
for the generalised Pareto distribution.
# logLikVector.Bernoulli bfit <- fitBernoulli(c(exdex::cheeseboro) > 45) bvec <- logLikVector(bfit) head(bvec) logLik(bvec) logLik(bfit) # estfun.generalisedPareto gpfit <- fitGP(c(exdex::cheeseboro), u = 45) gpvec <- logLikVector(gpfit) head(gpvec) logLik(gpvec) logLik(gpfit)
# logLikVector.Bernoulli bfit <- fitBernoulli(c(exdex::cheeseboro) > 45) bvec <- logLikVector(bfit) head(bvec) logLik(bvec) logLik(bfit) # estfun.generalisedPareto gpfit <- fitGP(c(exdex::cheeseboro), u = 45) gpvec <- logLikVector(gpfit) head(gpvec) logLik(gpvec) logLik(gpfit)
years.predict
method for class "blite". Performs predictive inference
about the largest value to be observed over a future time period of
years. Predictive inferences accounts for uncertainty in model
parameters and for uncertainty owing to the variability of future
observations.
## S3 method for class 'blite' predict( object, type = c("i", "p", "d", "q", "r"), x = NULL, x_num = 100, n_years = 100, ny = NULL, level = 95, hpd = FALSE, lower_tail = TRUE, log = FALSE, big_q = 1000, ... )
## S3 method for class 'blite' predict( object, type = c("i", "p", "d", "q", "r"), x = NULL, x_num = 100, n_years = 100, ny = NULL, level = 95, hpd = FALSE, lower_tail = TRUE, log = FALSE, big_q = 1000, ... )
object |
An object of class |
type |
A character vector. Indicates which type of inference is required:
|
x |
A numeric vector or a matrix with
|
x_num |
A numeric scalar. If |
n_years |
A numeric vector. Values of |
ny |
A numeric scalar. The (mean) number of observations per year. Setting this appropriately is important. See Details. |
level |
A numeric vector of values in (0, 100).
Only relevant when |
hpd |
A logical scalar.
Only relevant when If If |
lower_tail |
A logical scalar.
Only relevant when |
log |
A logical scalar. Only relevant when |
big_q |
A numeric scalar. Only relevant when |
... |
Additional optional arguments. At present no optional arguments are used. |
The function predict.evpost
in the
revdbayes
package is used to perform the
predictive inferences. The effect of adjusting for the values of the
extremal index in the posterior sample in
object$sim_vals[, "theta"]
is to change the effective time horizon
from to
.
ny
provides information about the (intended) frequency of
sampling in time, that is, the number of observations that would be
observed in a year if there are no missing values. If the number of
observations may vary between years then ny
should be set equal to
the mean number of observations per year.
Supplying ny
.
The value of ny
may have been set in the call to
blite
. If ny
is supplied by the user in the call to
predict.blite
then this will be used in preference to the value
stored in the fitted model object. If these two values differ then no
warning will be given.
An object of class "evpred", a list containing a subset of the following components:
type |
The argument |
x |
A matrix containing the argument |
y |
The content of
|
long |
A |
short |
A matrix with the same structure as |
The arguments n_years, level, hpd, lower_tail, log
supplied
to predict.blite
are also included, as is the value of ny
and model = "bingp"
.
### Cheeseboro wind gusts cdata <- exdex::cheeseboro # Each column of the matrix cdata corresponds to data from a different year # blite() sets cluster automatically to correspond to column (year) cpost <- blite(cdata, u = 45, k = 3, ny = 31 * 24) # Interval estimation predict(cpost)$long predict(cpost, hpd = TRUE)$short # Density function plot(predict(cpost, type = "d", n_years = c(100, 1000))) # Distribution function plot(predict(cpost, type = "p", n_years = c(100, 1000))) # Quantiles predict(cpost, type = "q", n_years = c(100, 1000))$y # Random generation plot(predict(cpost, type = "r"))
### Cheeseboro wind gusts cdata <- exdex::cheeseboro # Each column of the matrix cdata corresponds to data from a different year # blite() sets cluster automatically to correspond to column (year) cpost <- blite(cdata, u = 45, k = 3, ny = 31 * 24) # Interval estimation predict(cpost)$long predict(cpost, hpd = TRUE)$short # Density function plot(predict(cpost, type = "d", n_years = c(100, 1000))) # Distribution function plot(predict(cpost, type = "p", n_years = c(100, 1000))) # Quantiles predict(cpost, type = "q", n_years = c(100, 1000))$y # Random generation plot(predict(cpost, type = "r"))
Calculates point estimates and confidence intervals for m
-year
return levels for stationary time series fitted extreme value model objects
returned from flite
. Two types of interval may be returned:
(a) intervals based on approximate large-sample normality of the maximum
likelihood estimator for return level, which are symmetric about the point
estimate, and (b) profile likelihood-based intervals based on an (adjusted)
log-likelihood.
returnLevel( x, m = 100, level = 0.95, ny, prof = TRUE, inc = 1/100, type = c("vertical", "cholesky", "spectral", "none") )
returnLevel( x, m = 100, level = 0.95, ny, prof = TRUE, inc = 1/100, type = c("vertical", "cholesky", "spectral", "none") )
x |
An object inheriting from class |
m |
A numeric scalar. The return period, in years. |
level |
A numeric scalar in (0, 1). The confidence level required for
confidence interval for the |
ny |
A numeric scalar. The (mean) number of observations per year. Setting this appropriately is important. See Details. |
prof |
A logical scalar. Should we calculate intervals based on profile log-likelihood? |
inc |
A numeric scalar in (0, 1/2]. Only relevant if |
type |
A character scalar. The argument |
For information about return levels see the "Introducing lite" vignette.
ny
provides information about the (intended) frequency of
sampling in time, that is, the number of observations that would be
observed in a year if there are no missing values. If the number of
observations may vary between years then ny
should be set equal to
the mean number of observations per year.
Supplying ny
.
The value of ny
may have been set in the call to
flite
. If ny
is supplied by the user in the call to
returnLevel
then this will be used in preference to the value
stored in the fitted model object. If these two values differ then no
warning will be given.
For details of the definition and estimation of return levels see the Inference for return levels vignette.
The profile likelihood-based intervals are calculated by
reparameterising in terms of the m
-year return level and estimating
the values at which the (adjusted) profile log-likelihood reaches
the critical value logLik(x) - 0.5 * stats::qchisq(level, 1)
.
This is achieved by calculating the profile log-likelihood for a sequence
of values of this return level as governed by inc
. Once the profile
log-likelihood drops below the critical value the lower and upper limits
are estimated by interpolating linearly between the cases lying either
side of the critical value. The smaller inc
the more accurate (but
slower) the calculation will be.
A object (a list) of class "returnLevel", "lite"
with the
components
rl_sym , rl_prof
|
Named numeric vectors containing the respective
lower 100 |
rl_se |
Estimated standard error of the return level. |
max_loglik , crit , for_plot
|
If |
m , level
|
The input values of |
ny |
The value of |
call |
The call to |
Coles, S. G. (2001) An Introduction to Statistical Modeling of Extreme Values, Springer-Verlag, London. doi:10.1007/978-1-4471-3675-0_3
returnLevelMethods
, including plotting the (adjusted)
profile log-likelihood for a return level.
### Cheeseboro wind gusts # Make inferences cdata <- exdex::cheeseboro # Each column of the matrix cdata corresponds to data from a different year # flite() sets cluster automatically to correspond to column (year) cfit <- flite(cdata, u = 45, k = 3) # These data are hourly for one month (January) year so ny = 31 * 24 # Large inc set here for speed, sacrificing accuracy # Default 95% confidence intervals rl <- returnLevel(cfit, inc = 1 / 10, ny = 31 * 24) summary(rl) rl oldrl <- plot(rl) oldrl # Quickly recalculate/replot the intervals based on profile log-likelihood # provided that level is smaller than that used to produce rl newrl <- plot(rl, level = 0.9) newrl
### Cheeseboro wind gusts # Make inferences cdata <- exdex::cheeseboro # Each column of the matrix cdata corresponds to data from a different year # flite() sets cluster automatically to correspond to column (year) cfit <- flite(cdata, u = 45, k = 3) # These data are hourly for one month (January) year so ny = 31 * 24 # Large inc set here for speed, sacrificing accuracy # Default 95% confidence intervals rl <- returnLevel(cfit, inc = 1 / 10, ny = 31 * 24) summary(rl) rl oldrl <- plot(rl) oldrl # Quickly recalculate/replot the intervals based on profile log-likelihood # provided that level is smaller than that used to produce rl newrl <- plot(rl, level = 0.9) newrl
"returnLevel"
Methods for objects of class "returnLevel"
returned from
returnLevel
.
## S3 method for class 'returnLevel' plot(x, level = NULL, legend = TRUE, digits = 3, plot = TRUE, ...) ## S3 method for class 'returnLevel' print(x, digits = max(3L, getOption("digits") - 3L), ...) ## S3 method for class 'returnLevel' summary(object, digits, ...) ## S3 method for class 'summary.returnLevel' print(x, ...)
## S3 method for class 'returnLevel' plot(x, level = NULL, legend = TRUE, digits = 3, plot = TRUE, ...) ## S3 method for class 'returnLevel' print(x, digits = max(3L, getOption("digits") - 3L), ...) ## S3 method for class 'returnLevel' summary(object, digits, ...) ## S3 method for class 'summary.returnLevel' print(x, ...)
x |
an object of class |
level |
A numeric scalar in (0, 1). The confidence level required for
the confidence interval for the |
legend |
A logical scalar. Should we add a legend (in the top right
of the plot) that gives the approximate values of the MLE and
100 |
digits |
For For For |
plot |
A logical scalar. If |
... |
For For |
object |
an object of class |
plot.returnLevel
plots the profile log-likelihood for a
return level, provided that x
returned by a call to
returnLevel
using prof = TRUE
. Horizontal lines
indicate the values of the maximised log-likelihood and the critical level
used to calculate the confidence limits.
If level
is smaller than x$level
then approximate
100level
% confidence limits are recalculated based on the
information contained in x$for_plot
.
print.returnLevel
prints the call to
returnLevel
and the estimates and 100x$level
%
confidence limits for the x$m
-year return level.
plot.returnLevel
: a numeric vector of length 3 containing the
lower 100level
% confidence limit, the MLE and the upper
100level
% confidence limit is returned invisibly.
print.returnLevel
: the argument x
is returned, invisibly.
summary.returnLevel
: a list containing the list element
object$call
and a matrix matrix
containing the MLE
and estimated SE of the return level.
print.summary.returnLevel
: the argument x
is returned,
invisibly.
See returnLevel
.
returnLevel
to perform frequentist threshold-based
inference for return levels.