twosidedpval {skedastic}R Documentation

Computation of Conditional Two-Sided pp-Values

Description

Computes the conditional pp-value PCP_C for a continuous or discrete test statistic, as defined in Kulinskaya (2008). This provides a method for computing a two-sided pp-value from an asymmetric null distribution.

Usage

twosidedpval(
  q,
  CDF,
  continuous,
  method = c("doubled", "kulinskaya", "minlikelihood"),
  locpar,
  supportlim = c(-Inf, Inf),
  ...
)

Arguments

q

A double representing the quantile, i.e. the observed value of the test statistic for which a two-sided pp-value is to be computed

CDF

A function representing the cumulative distribution function of the test statistic under the null hypothesis, i.e. Pr(TqH0)\Pr(T\le q|\mathrm{H}_0).

continuous

A logical indicating whether the test statistic is a continuous (TRUE) or discrete (FALSE) random variable. Defaults to TRUE.

method

A character specifying the method to use to calculate two-sided pp-value; one of "doubled" (representing doubling of the one-sided pp-value), "kulinskaya" (representing the method of Kulinskaya (2008)), or "minlikelihood" (representing the sum of probabilities for values with probability less than or equal to that of the observed value. Partial matching is used. Note that the "minlikelihood" method is available only for discrete distributions.

locpar

a double representing a generic location parameter chosen to separate the tails of the distribution. Note that if locpar corresponds to the median of CDF, there is no difference between the two methods, in the continuous case. If locpar is not specified, the function attempts to compute the expectation of CDF using numerical integration and, if successful, uses this as locpar. However, this may yield unexpected results, especially if CDF is not one of the cumulative distribution functions of well-known distributions included in the stats package.

supportlim

A numeric vector of length 2, giving the minimum and maximum values in the support of the distribution whose cumulative distribution function is CDF. This argument is only used if the distribution is discrete (i.e. if continuous is FALSE) and if method is "minlikelihood" or locpar is not specified. If supportlim is not supplied, the function assumes that the support is -1e6:1e6. Values of -Inf and Inf may be supplied, but if so, the support is truncated at -1e6 and 1e6 respectively.

...

Optional arguments to pass to CDF.

Details

Let TT be a statistic that, under the null hypothesis, has cumulative distribution function FF and probability density or mass function ff. Denote by AA a generic location parameter chosen to separate the two tails of the distribution. Particular examples include the mean E(TH0)E(T|\mathrm{H}_0), the mode argsuptf(t)\arg \sup_{t} f(t), or the median F1(12)F^{-1}\left(\frac{1}{2}\right). Let qq be the observed value of TT.

In the continuous case, the conditional two-sided pp-value centered at AA is defined as

PCA(q)=F(q)F(A)1qA+1F(q)1F(A)1q>AP_C^A(q)=\frac{F(q)}{F(A)}1_{q \le A} + \frac{1-F(q)}{1-F(A)}1_{q > A}

where 11_{\cdot} is the indicator function. In the discrete case, PCAP_C^A depends on whether AA is an attainable value within the support of TT. If AA is not attainable, the conditional two-sided pp-value centred at AA is defined as

PCA(q)=Pr(Tq)Pr(T<A)1q<A+Pr(Tq)Pr(T>A)1q>AP_C^{A}(q)=\frac{\Pr(T\le q)}{\Pr(T<A)}1_{q<A} + \frac{\Pr(T\ge q)}{\Pr(T>A)}1_{q>A}

If AA is attainable, the conditional two-sided pp-value centred at AA is defined as

PCA(q)=Pr(Tq)Pr(TA)/(1+Pr(T=A))1q<A+1q=A+Pr(Tq)Pr(TA)/(1+Pr(T=A))1q>AP_C^{A}(q)=\frac{\Pr(T\le q)}{\Pr(T\le A)/\left(1+\Pr(T=A)\right)} 1_{q<A} + 1_{q=A}+\frac{\Pr(T\ge q)}{\Pr(T \ge A)/\left(1+\Pr(T=A)\right)} 1_{q>A}

Value

A double.

References

Kulinskaya E (2008). “On Two-Sided p-Values for Non-Symmetric Distributions.” 0810.2124, 0810.2124.

Examples

# Computation of two-sided p-value for F test for equality of variances
n1 <- 10
n2 <- 20
set.seed(1234)
x1 <- stats::rnorm(n1, mean = 0, sd = 1)
x2 <- stats::rnorm(n2, mean = 0, sd = 3)
# 'Conventional' two-sided p-value obtained by doubling one-sided p-value:
stats::var.test(x1, x2, alternative = "two.sided")$p.value
# This is replicated in `twosidedpval` by setting `method` argument to `"doubled"`
twosidedpval(q = var(x1) / var(x2), CDF = stats::pf, continuous = TRUE,
 method = "doubled", locpar = 1, df1 = n1 - 1, df2 = n2 - 1)
# Conditional two-sided p-value centered at df (mean of chi-squared r.v.):
twosidedpval(q = var(x1) / var(x2), CDF = stats::pf, continuous = TRUE,
 method = "kulinskaya", locpar = 1, df1 = n1 - 1, df2 = n2 - 1)

[Package skedastic version 2.0.2 Index]