Last chance! 50% off unlimited learning
Sale ends in
fgngcon(x, phiul = TRUE, phiur = TRUE, pvector = NULL,
std.err = TRUE, method = "BFGS",
control = list(maxit = 10000), finitelik = TRUE, ...)
NULL
optim
)optim
)optim
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 model parameters,
including sigmaul
, sigmaur
and tail
fractions phiul
and phiur
allse
:
vector of standard error of model parameters,
including sigmaul
, sigmaur
and tail
fractions phiul
and phiur
n
: total sample size
nmean
: MLE of normal
mean
nsd
: MLE of normal standard
deviation
ul
: lower threshold
sigmaul
: MLE of lower tail GPD scale
xil
: MLE of lower tail GPD shape
phiul
: MLE of lower tail fraction
ur
: upper threshold
sigmaur
: MLE of upper tail GPD scale
xir
: MLE of
upper tail GPD shape
phiur
: MLE of upper
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.pvector
is (nmean
, nsd
, ul
,
sigmaul
, xil
, ur
, sigmaur
,
xir
)
The default values for phiul=TRUE
and
phiur=TRUE
so that the corresponding tail
fractions are specified by normal distribution
$\phi_{ul} = H(u_l)$ and $\phi_{ur} = 1 -
H(u_r)$. When phiul=FALSE
and phiur=FALSE
then the corresponding tail fractions are treated as an
extra parameter estimated using the MLE which is the
sample proportion beyond the corresponding threshold. In
this case the standard error for phiul
and
phiur
are estimated and output as sephiul
and sephiur
.
Missing values (NA
and NaN
) are assumed to
be invalid data so are ignored, which is inconsistent
with the evd
library which
assumes the missing values are below the threshold.
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
.fgng
,
fnormgpd
,
lgpd
and
gpd
Other gngcon: dgngcon
,
gngcon
, lgngcon
,
nlgngcon
, pgngcon
,
qgngcon
, rgngcon
par(mfrow=c(2,2))
x = rnorm(1000)
xx = seq(-6, 6, 0.01)
y = dnorm(xx)
# Bulk model base tail fraction
fit = fgngcon(x, phiul = TRUE, phiur = TRUE, std.err = FALSE)
hist(x, breaks = 100, freq = FALSE, xlim = c(-6, 6), main = "N(0, 1)")
lines(xx, y)
lines(xx, dgngcon(xx, nmean = fit$nmean, nsd = fit$nsd,
ul = fit$ul, xil = fit$xil, phiul = TRUE,
ur = fit$ur, xir = fit$xir, phiur = TRUE), col="red")
abline(v = c(fit$ul, fit$ur))
# Parameterised tail fraction
fit2 = fgngcon(x, phiul = TRUE, phiur = TRUE, std.err = FALSE)
plot(xx, y, type = "l")
lines(xx, dgngcon(xx, nmean = fit$nmean, nsd = fit$nsd,
ul = fit$ul, xil = fit$xil, phiul = TRUE,
ur = fit$ur, xir = fit$xir, phiur = TRUE), col="red")
lines(xx, dgngcon(xx, nmean = fit2$nmean, nsd = fit2$nsd,
ul = fit2$ul, xil = fit2$xil, phiul = fit2$phiul,
ur = fit2$ur, xir = fit2$xir, phiur = fit2$phiur), col="blue")
abline(v = c(fit$ul, fit$ur), col = "red")
abline(v = c(fit2$ul, fit2$ur), col = "blue")
legend("topright", c("True Density","Bulk Tail Fraction","Parameterised Tail Fraction"),
col=c("black", "red", "blue"), lty = 1)
x = rnorm(1000)
xx = seq(-6, 6, 0.01)
y = dnorm(xx)
# Two tail is safest if bulk has lower tail which is not normal tail
x = rt(1000, df = 3)
xx = seq(-10, 10, 0.01)
y = dt(xx, df = 3)
# Bulk model base tail fraction
fit = fnormgpd(x, phiu = FALSE, std.err = FALSE)
fit2 = fgngcon(x, phiul = FALSE, phiur = FALSE, std.err = FALSE)
hist(x, breaks = 100, freq = FALSE, xlim = c(-10, 10), main = "t (df=3)")
lines(xx, y)
lines(xx, dnormgpd(xx, nmean = fit$nmean, nsd = fit$nsd,
u = fit$u, sigmau = fit$sigmau, xi = fit$xi, phiu = fit$phiu), col="red")
abline(v = fit$u)
# Bulk model base tail fraction
plot(xx, y, type = "l")
lines(xx, dnormgpd(xx, nmean = fit$nmean, nsd = fit$nsd,
u = fit$u, sigmau = fit$sigmau, xi = fit$xi, phiu = fit$phiu), col="red")
lines(xx, dgngcon(xx, nmean = fit2$nmean, nsd = fit2$nsd,
ul = fit2$ul, xil = fit2$xil, phiul = fit2$phiul,
ur = fit2$ur, xir = fit2$xir, phiur = fit2$phiur), col="blue")
abline(v = c(fit$ul, fit$ur), col = "red")
abline(v = c(fit2$ul, fit2$ur), col = "blue")
legend("topright", c("True Density","GPD Upper Tail Only","GPD Both Tails"),
col=c("black", "red", "blue"), lty = 1)
Run the code above in your browser using DataLab