Learn R Programming

logcondens (version 2.1.8)

quantilesLogConDens: Function to compute Quantiles of Fhat

Description

Function to compute \(p_0\)-quantile of

$$\widehat F_m(t) = \int_{x_1}^t \widehat f_m(t) dt,$$

where \(\widehat f_m\) is the log-concave density estimator, typically computed via logConDens and \(p_0\) runs through the vector ps. The formula to compute a quantile at \(u \in [\widehat F_m(x_j), \widehat F_m(x_{j+1})]\) for \(j = 1, \ldots, n-1\) is:

$$\widehat F_m^{-1}(u) = x_j + (x_{j+1}-x_j) G^{-1}_{(x_{j+1}-x_j)(\widehat \phi_{j+1}-\widehat \phi_j)} \Big( \frac{u - \widehat F_m(x_j)}{ \widehat F_m(x_{j+1}) - \widehat F_m(x_j)}\Big),$$

where \(G^{-1}_\theta\) is described in qloglin.

Usage

quantilesLogConDens(ps, res)

Value

Returns a data.frame with row \((p_{0, i}, q_{0, i})\) where \(q_{0, i} = \inf_{x}\{\widehat F_m(x) \ge p_{0, i}\}\) and \(p_{0, i}\) runs through ps.

Arguments

ps

Vector of real numbers where quantiles should be computed.

res

An object of class "dlc", usually a result of a call to logConDens.

Examples

Run this code
## estimate gamma density
set.seed(1977)
x <- rgamma(200, 2, 1)
res <- logConDens(x, smoothed = FALSE, print = FALSE)

## compute 0.95 quantile of Fhat
q <- quantilesLogConDens(0.95, res)[, "quantile"]
plot(res, which = "CDF", legend.pos = "none")
abline(h = 0.95, lty = 3); abline(v = q, lty = 3)

Run the code above in your browser using DataLab