twosidedpval {skedastic} | R Documentation |
Computation of Conditional Two-Sided
-Values
Description
Computes the conditional -value
for a continuous
or discrete test statistic, as defined in
Kulinskaya (2008). This provides a method
for computing a two-sided
-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 |
CDF |
A function representing the cumulative distribution function of
the test statistic under the null hypothesis, i.e.
|
continuous |
A logical indicating whether the test statistic is a
continuous ( |
method |
A character specifying the method to use to calculate
two-sided |
locpar |
a double representing a generic location parameter chosen to
separate the tails of the distribution. Note that if |
supportlim |
A numeric vector of |
... |
Optional arguments to pass to |
Details
Let be a statistic that, under the null hypothesis, has
cumulative distribution function
and probability density or mass
function
. Denote by
a generic location parameter chosen
to separate the two tails of the distribution. Particular examples
include the mean
, the mode
, or the median
. Let
be the observed value
of
.
In the continuous case, the conditional two-sided -value centered
at
is defined as
where is the indicator function. In the discrete case,
depends on whether
is an attainable value within the
support of
. If
is not attainable, the conditional two-sided
-value centred at
is defined as
If is attainable, the conditional two-sided
-value centred
at
is defined as
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)