twosidedpval | R Documentation |
p
-ValuesComputes the conditional p
-value P_C
for a continuous
or discrete test statistic, as defined in
\insertCiteKulinskaya08;textualskedastic. This provides a method
for computing a two-sided p
-value from an asymmetric null
distribution.
twosidedpval(
q,
CDF,
continuous,
method = c("doubled", "kulinskaya", "minlikelihood"),
locpar,
supportlim = c(-Inf, Inf),
...
)
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 |
Let T
be a statistic that, under the null hypothesis, has
cumulative distribution function F
and probability density or mass
function f
. Denote by A
a generic location parameter chosen
to separate the two tails of the distribution. Particular examples
include the mean E(T|\mathrm{H}_0)
, the mode
\arg \sup_{t} f(t)
, or the median
F^{-1}\left(\frac{1}{2}\right)
. Let q
be the observed value
of T
.
In the continuous case, the conditional two-sided p
-value centered
at A
is defined as
P_C^A(q)=\frac{F(q)}{F(A)}1_{q \le A} + \frac{1-F(q)}{1-F(A)}1_{q > A}
where 1_{\cdot}
is the indicator function. In the discrete case,
P_C^A
depends on whether A
is an attainable value within the
support of T
. If A
is not attainable, the conditional two-sided
p
-value centred at A
is defined as
P_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 A
is attainable, the conditional two-sided p
-value centred
at A
is defined as
P_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}
A double.
# 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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.