quantileDRM: Estimate the quantiles of the populations under the DRM

Description Usage Arguments Details Value References Examples

View source: R/drmdel.R

Description

Suppose we have m+1 samples, labeled as 0, 1, ..., m, whose population distributions satisfy the density ratio model (DRM) (see drmdel for the definition of DRM). The quantileDRM function estimates the quantiles of the population distributions.

Usage

1
2
quantileDRM(k, p, drmfit, cov=TRUE, interpolation=TRUE,
            adj=FALSE, adj_val=NULL, bw=NULL, show_bw=FALSE)

Arguments

k

a vector of labels of populations whose quantiles are to be estimated, with k[i] = 0, 1, ..., m. It could also be a single integer value (in the set of 0, 1, ..., m), in which case, it means that we estimate the quantile of the same population at each of the probability value p (see below for the explaination of argument "p").

p

a vector of probabilities (the same length as argument "k") at which the quantiles are estimated; It could also be a single value, in which case, it means that for each population k, we estimate the quantile at a same probability value.

drmfit

a fitted DRM object (an output from the drmdel function). See drmdel for details.

cov

a logical variable specifying whether to estimate the covariance matrix of the quantile estimators. The default is TRUE.

interpolation

The EL quantile estimator is based on the EL CDF estimator. Hence the way the EL CDF estimate is calculated affects the result of the quantile estimation. This argument is to be passed to the cdfDRM function for tweaking the EL CDF estimator. See cdfDRM for details.

adj

a logical variable specifying whether to adjust the CDF estimation by adding a term when estimating quantiles; The default is FALSE. See "Details" section.

adj_val

a vector of the same length as the argument "k" (or as the argument "p" if the length of "k" is 1) containing the values of adjustment terms for lower or higher quantile estimation, if adj=TRUE. The default value, NULL, uses -1/2*n_k[i], where n_k[i] is the size of the k^th sample sample, for each i, to adjust the EL quantile estimator for lower quantile estimation. See "Details" section

bw

a vector of bandwidths (the same length as the argument "k") for kernel density estimation required for estimating the covariance matrix of the quantile estimators; It could also be a single value, in which case, it means that for each population k, we use the same bandwidth. The default bandwidth, NULL, uses that described in Chen and Liu (2013).

show_bw

a logical variable specifying whether to output bandwidths when argument cov=TRUE. The default is FALSE.

Details

Denote the estimated CDF of the k^th population as Fhat_k(x). The p^th quantile of F_k(x) then is estimated as

inf{x: Fhat_k(x) >= p}.

The estimated CDF Fhat_k(x) reaches its maximum value, 1, at the largest observed data point. If the true CDF F_k(x) is continuous, F_k(x) tends to 1 when x tends to infinity. Hence, when estimate an upper quanitle, say 0.95^th quantile, of F_k, the quantile estimator is likely to under estimate the ture quantile, especially when sample size is not too large. To adjust an upper quantile estimator for possible under-estimation, one may want to adjust the estimated CDF as

Fhat_k(x) + adj_val.

and use the adjusted CDF to estimate quantiles. To make an upper quantile estimator larger, the adj_val should have a positive value. Similarly, to adjust lower quantile estimates for possible over-estimation, the adj_val should have a negative value.

The quantileDRM function, by default, does not adjust CDF estimators (adjust=FALSE). When adjust=TRUE, the default adj_val is set to -1/2*n_k[i], where n_k[i] is the size of the k^th sample sample, for each i, to adjust the EL quantile estimator for lower quantile estimation.

Value

est

quantile estimates.

cov

estimated covariance matrix of the quantile estimators, available only if argument cov=TRUE.

bw

bandwidths used for kernel density estimation required for estimating the covariance matrix of the quantile estimators, available only if argument cov=TRUE and show_bw=TRUE.

References

J. Chen and Y. Liu (2013), Quantile and quantile-function estimations under density ratio model. The Annals of Statistics, 41(3):1669-1692.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# Data generation
set.seed(25)
n_samples <- c(100, 200, 180, 150, 175)  # sample sizes
x0 <- rgamma(n_samples[1], shape=5, rate=1.8)
x1 <- rgamma(n_samples[2], shape=12, rate=1.2)
x2 <- rgamma(n_samples[3], shape=12, rate=1.2)
x3 <- rgamma(n_samples[4], shape=18, rate=5)
x4 <- rgamma(n_samples[5], shape=25, rate=2.6)
x <- c(x0, x1, x2, x3, x4)

# Fit a DRM with the basis function q(x) = (x, log(abs(x))),
# which is the basis function for gamma family. This basis
# function is the built-in basis function 6.
drmfit <- drmdel(x=x, n_samples=n_samples, basis_func=6)

# Quantile estimation
# Denote the p^th quantile of the k^th, k=0, 1, ..., 4,
# population as q_{k,p}.

# Estimate q_{0,0.25}, q_{0,0.6}, q_{1,0.1} and q_{2,0.1}.
(qe <- quantileDRM(k=c(0, 0, 1, 2), p=c(0.25, 0.6, 0.1, 0.1),
                  drmfit=drmfit))

# Estimate the 0.05^th, 0.2^th and 0.8^th quantiles of F_3
(qe1 <- quantileDRM(k=3, p=c(0.05, 0.2, 0.8), drmfit=drmfit))
 
# Estimate the 0.05^th quantiles of F_1, F_3 and F_4
(qe2 <- quantileDRM(k=c(1 , 3, 4), p=0.05, drmfit=drmfit))

Example output

$est
[1] 1.745160 2.562878 6.823404 6.602502

$cov
            [,1]         [,2]         [,3]         [,4]
[1,] 7.323288660  6.240822092  0.003417221  0.002580769
[2,] 6.240822092 20.349043999  0.018804714  0.005719943
[3,] 0.003417221  0.018804714 35.899053950  6.014607198
[4,] 0.002580769  0.005719943  6.014607198 45.180186104

$est
[1] 2.274920 2.831563 4.336181

$cov
         [,1]     [,2]     [,3]
[1,] 6.809338 4.474482 1.044709
[2,] 4.474482 7.566300 2.468381
[3,] 1.044709 2.468381 8.913955

$est
[1] 6.142071 2.274920 6.510105

$cov
            [,1]        [,2]        [,3]
[1,] 34.76069197 -0.01066012  3.46728600
[2,] -0.01066012  6.80933767 -0.03228694
[3,]  3.46728600 -0.03228694 26.67562549

drmdel documentation built on Oct. 25, 2021, 5:07 p.m.

Related to quantileDRM in drmdel...