P-Splines Density Estimate and GPD Tail Extreme Value Mixture Model
P-Splines Density Estimate and GPD Tail Extreme Value Mixture Model
Density, cumulative distribution function, quantile function and random number generation for the extreme value mixture model with P-splines density estimate for bulk distribution upto the threshold and conditional GPD above threshold. The parameters are the B-spline coefficients beta (and associated features), threshold u
GPD scale sigmau and shape xi and tail fraction phiu.
nbinwidth: scaling to convert count frequency into proper density
xrange: vector of minimum and maximum of B-spline (support of density)
nseg: number of segments between knots
degree: degree of B-splines (0 is constant, 1 is linear, etc.)
u: threshold
sigmau: scale parameter (positive)
xi: shape parameter
phiu: probability of being above threshold [0,1] or TRUE
design.knots: spline knots for splineDesign function
log: logical, if TRUE then log density
q: quantiles
lower.tail: logical, if FALSE then upper tail probabilities
p: cumulative probabilities
n: sample size (positive integer)
Returns
dpsdengpd gives the density, ppsdengpd gives the cumulative distribution function, qpsdengpd gives the quantile function and rpsdengpd gives a random sample.
Details
Extreme value mixture model combining P-splines density estimate for the bulk below the threshold and GPD for upper tail.
The user can pre-specify phiu
permitting a parameterised value for the tail fraction ϕu. Alternatively, when phiu=TRUE the tail fraction is estimated as the tail fraction from the KDE bulk model.
The cumulative distribution function with tail fraction ϕu defined by the upper tail fraction of the P-splines density estimate (phiu=TRUE), upto the threshold x≤u, given by:
F(x)=H(x)
and above the threshold x>u:
F(x)=H(u)+[1−H(u)]G(x)
where H(x) and G(X) are the P-splines density estimate and conditional GPD cumulative distribution functions respectively.
The cumulative distribution function for pre-specified ϕu, upto the threshold x≤u, is given by:
F(x)=(1−ϕu)H(x)/H(u)
and above the threshold x>u:
F(x)=ϕu+[1−ϕu]G(x)
Notice that these definitions are equivalent when ϕu=1−H(u).
See gpd for details of GPD upper tail component. The specification of the underlying B-splines and the P-splines density estimator are discussed in the psden function help.
Note
Unlike most of the other extreme value mixture model functions the psdengpd functions have not been vectorised as this is not appropriate. The main inputs (x, p or q) must be either a scalar or a vector, which also define the output length. The B-splines coefficients beta and knots design.knots are vectors.
Default values are provided for P-spline inputs of degree and nseg only, but all others must be provided by the user. The default sample size for rpsdengpd is 1.
Missing (NA) and Not-a-Number (NaN) values in x, p and q are passed through as is and infinite values are set to NA. None of these are permitted for the parameters/B-spline criteria.
Due to symmetry, the lower tail can be described by GPD by negating the quantiles.
Error checking of the inputs (e.g. invalid probabilities) is carried out and will either stop or give warning message as appropriate.
Examples
## Not run:set.seed(1)par(mfrow = c(1,1))x = rnorm(1000)xx = seq(-6,6,0.01)y = dnorm(xx)# Plenty of histogram bins (100)breaks = seq(-4,4, length.out=101)# P-spline fitting with cubic B-splines, 2nd order penalty and 8 internal segments# CV search for penalty coefficient. fit = fpsdengpd(x, lambdaseq =10^seq(-5,5,0.25), breaks = breaks, xrange = c(-4,4), nseg =10, degree =3, ord =2)hist(x, freq =FALSE, breaks = seq(-4,4, length.out=101), xlim = c(-6,6))# P-splines onlywith(fit, lines(xx, dpsden(xx, beta, nbinwidth, design = design.knots), lwd =2, col ="blue"))# P-splines+GPDwith(fit, lines(xx, dpsdengpd(xx, beta, nbinwidth, design = design.knots, u = u, sigmau = sigmau, xi = xi, phiu = phiu), lwd =2, col ="red"))abline(v = fit$u, col ="red")legend("topleft", c("True Density","P-spline density","P-spline+GPD"), col=c("black","blue","red"), lty =1)## End(Not run)
Scarrott, C.J. and MacDonald, A. (2012). A review of extreme value threshold estimation and uncertainty quantification. REVSTAT - Statistical Journal 10(1), 33-59. Available from http://www.ine.pt/revstat/pdf/rs120102.pdf
Eilers, P.H.C. and Marx, B.D. (1996). Flexible smoothing with B-splines and penalties. Statistical Science 11(2), 89-121.