Computes the conditional
twosidedpval(
q,
CDF,
continuous,
method = c("doubled", "kulinskaya", "minlikelihood"),
locpar,
supportlim = c(-Inf, Inf),
...
)
A double.
A double representing the quantile, i.e. the observed value of the
test statistic for which a two-sided
A function representing the cumulative distribution function of
the test statistic under the null hypothesis, i.e.
A logical indicating whether the test statistic is a
continuous (TRUE
) or discrete (FALSE
) random variable.
Defaults to TRUE
.
A character specifying the method to use to calculate
two-sided "doubled"
(representing
doubling of the one-sided "kulinskaya"
(representing the method of
Kulinskaya08;textualskedastic), 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.
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.
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
.
Let
In the continuous case, the conditional two-sided
# 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)
Run the code above in your browser using DataLab