statcompute {PoweR} | R Documentation |
Performs a hypothesis test for the given value of statistic.
Description
Performs the hypothesis test for those added in the package.
Usage
statcompute(stat.index, data, levels = c(0.05,0.1), critvalL = NULL,
critvalR = NULL, alter = 0, stat.pars = NULL, pvalcomp = 1L,
check = TRUE)
Arguments
stat.index |
one statistic index as given by function
|
data |
sample from which to compute the statistic. |
levels |
vector of desired significance levels for the test. |
critvalL |
|
critvalR |
|
alter |
0: two.sided=bilateral, 1: less=unilateral, 2: greater=unilateral, 3: bilateral test that rejects H0 only for large values of the test statistic, 4: bilateral test that rejects H0 only for small values of the test statistic. |
stat.pars |
a vector of parameters.
If |
pvalcomp |
|
check |
Logical. If |
Details
The function statcompute() should not be used in simulations since it is
NOT fast. Consider instead using powcomp.easy
or
powcomp.fast
. See also in the Example section below for a fast
approach using the .C
function (but be warned that giving wrong
values of arguments can crash your session!).
Value
A list with components:
statistic |
the test statistic value |
pvalue |
the |
decision |
the vector of decisions, same length as |
alter |
|
stat.pars |
|
symbol |
how the test is noted |
Author(s)
P. Lafaye de Micheaux, V. A. Tran
References
Pierre Lafaye de Micheaux, Viet Anh Tran (2016). PoweR: A Reproducible Research Tool to Ease Monte Carlo Power Simulation Studies for Studies for Goodness-of-fit Tests in R. Journal of Statistical Software, 69(3), 1–42. doi:10.18637/jss.v069.i03
Examples
data <- rnorm(50)
# Shapiro-Wilk test:
statcompute(21, data, levels = c(0.05, 0.1), critvalL = NULL, critvalR = NULL,
alter = 0, stat.pars = NULL)
# Identical to:
shapiro.test(data)
# The function statcompute() should not be used in simulations since it
# is NOT fast. Consider instead the call below (but see the Details
# Section):
.C("stat21", data = data, n = 50L, levels = 0.05, nblevels = 1L, name =
rep(" ", 50), getname = 0L, statistic = 0, pvalcomp = 1L, pvalue = 0, cL = 0.0,
cR = 0.0, usecrit = 0L, alter = 4L, decision = 0L, stat.pars = 0.0,
nbparstat = 0L)
# Another option is to use the 'pvalcomp' and 'check' arguments as
# follows which can be much faster (when computing the p-value takes time)
statcompute(21, data, levels = c(0.05, 0.1), critvalL = NULL, critvalR = NULL,
alter = 0, stat.pars = NULL, pvalcomp = 0L, check = FALSE)