Learn R Programming

evmix (version 1.0)

fgpd: MLE Fitting of Generalised Pareto Distribution (GPD)

Description

Maximum likelihood estimation for fitting the GPD with parameters scale sigmau and shape xi to the threshold exceedances, conditional on being above a threshold u. Unconditional likelihood fitting also provided when the probability phiu of being above the threshold u is given.

Usage

fgpd(x, u = 0, phiu = NULL, pvector = NULL,
    std.err = TRUE, method = "BFGS", finitelik = TRUE, ...)

Arguments

x
vector of sample data
pvector
vector of initial values of GPD parameters (sigmau, xi) or NULL
phiu
probability of being above threshold [0,1] or NULL
std.err
logical, should standard errors be calculated
method
optimisation method (see optim)
finitelik
logical, should log-likelihood return finite value for invalid parameters
...
optional inputs passed to optim
u
threshold

Value

  • Returns a simple list with the following elements ll{ call: optim call x: data vector x init: pvector optim: complete optim output mle: vector of MLE of model parameters cov: variance-covariance matrix of MLE of model parameters se: vector of standard errors of MLE of model parameters rate: phiu to be consistent with evd nllh: minimum negative log-likelihood allparams: vector of MLE of GPD parameters and (possibly given) phiu allse: vector of standard error of GPD parameters and (possibly given) phiu n: total sample size u: threshold sigmau: MLE of GPD scale xi: MLE of GPD shape phiu: MLE of tail fraction } The output list has some duplicate entries and repeats some of the inputs to both provide similar items to those from fpot and to make it as useable as possible.

Details

The GPD is fitted to the exceedances of the threshold u using maximum likelihood estimation. The estimated parameters, variance-covariance matrix and their standard errors are automatically output. The default value for phiu is NULL, which means it will be estimated as the MLE of the tail fraction which is the sample proportion above the threshold. In this case the standard error for phiu is estimated and output as sephiu. Consistent with the evd library the missing values (NA and NaN) are assumed to be below the threshold. Otherwise, phiu can be specified as any value over [0, 1] leading to the unconditional log-likelihood being used for estimation. In this case the standard error will be output as NA. The value of phiu does not effect the GPD parameter estimates, only the value of the likelihood, as: $$L(\sigma_u, \xi; u, \phi_u) = (\phi_u ^ {n_u}) L(\sigma_u, \xi; u, \phi_u=1)$$ where the GPD has scale $\sigma_u$ and shape $\xi$, the threshold is $u$ and $nu$ is the number of exceedances. A non-unit value for phiu simply scales the likelihood, and shifts the log-likelihood, thus the GPD parameter estimates are invariant to phiu. The default optimisation algorithm is "BFGS", which requires a finite negative log-likelihood function evaluation finitelik=TRUE. For invalid parameters, a zero likelihood is replaced with exp(-1e6). The "BFGS" optimisation algorithms require finite values for likelihood, so any user input for finitelik will be overridden and set to finitelik=TRUE if either of these optimisation methods is chosen. It will display a warning for non-zero convergence result comes from optim function call. If the hessian is of reduced rank then the variance covariance (from inverse hessian) and standard error of parameters cannot be calculated, then by default std.err=TRUE and the function will stop. If you want the parameter estimates even if the hessian is of reduced rank (e.g. in a simulation study) then set std.err=FALSE.

References

Based on GPD fitting function in the evd package. http://en.wikipedia.org/wiki/Generalized_Pareto_distribution

See Also

dgpd, fpot and fitdistr Other gpd: dgpd, gpd, lgpd, nlgpd, pgpd, qgpd, rgpd

Examples

Run this code
par(mfrow=c(2,1))
x = rgpd(1000, u = 10, sigmau = 5, xi = 0.2)
xx = seq(0, 100, 0.1)
hist(x, breaks = 100, freq = FALSE, xlim = c(0, 100))
lines(xx, dgpd(xx, u = 10, sigmau = 5, xi = 0.2))
fit = fgpd(x, u = 10, phiu = NULL, std.err = FALSE)
lines(xx, dgpd(xx, u = fit$u, sigmau = fit$sigmau, xi = fit$xi), col="red")

# This time with phiu
x = rnorm(10000)
xx = seq(-4, 4, 0.01)
hist(x, breaks = 200, freq = FALSE, xlim = c(0, 4))
lines(xx, dnorm(xx), lwd = 2)
fit = fgpd(x, u = 1, phiu = NULL, std.err = FALSE)
lines(xx, dgpd(xx, u = fit$u, sigmau = fit$sigmau, xi = fit$xi, phiu = fit$phiu),
  col = "red", lwd = 2)
legend("topright", c("True Density","Fitted Density"), col=c("black", "red"), lty = 1)

Run the code above in your browser using DataLab