powcomp.fast {PoweR} | R Documentation |
Computation of power and level tables for hypothesis tests.
Description
Functions for the computation of power and level tables for hypothesis tests, with possible use of a cluster.
Usage
powcomp.fast(law.indices,stat.indices,vectn = c(20,50,100),M = 10^3,levels = c(0.05,0.1),
critval = NULL,alter = create.alter(stat.indices),parlaws = NULL,
parstats = NULL,nbclus = 1,model = NULL,null.law.index = 2,null.law.pars = NULL,
Rlaws=NULL, Rstats = NULL, center=FALSE, scale=FALSE, pvalcomp = 1L)
Arguments
law.indices |
vector of law indices as given by function |
stat.indices |
vector of statistic indices as given by function |
vectn |
vector of sample sizes ( |
M |
number of Monte Carlo repetitions. |
levels |
vector of significance levels for the test. |
critval |
if not |
alter |
named-list of integer values (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). The names of the list should be |
parlaws |
named-list of parameter values for each law to
simulate. The names of the list should be |
parstats |
named-list of parameter values for each statistic to simulate.
The names of the list should be |
nbclus |
number of slaves to use for the computation on a cluster. This needs parallel or Rmpi package to be installed and functionnal on the system. Also the mpd daemon sould be started. |
model |
NOT YET IMPLEMENTED. If |
null.law.index |
index of the law under the null. Only used, by
|
null.law.pars |
vector of parameters corresponding to
|
Rlaws |
When some law indices in 'law.indices' are equal to 0, this means that you will be using some R random generators. In that case, you should provide the names of the random generation functions in the corresponding components of 'Rlaws' list, the other components should be set to NULL. |
Rstats |
A list. If in a given row of the 'params' matrix, the value of 'stat' is set to 0, the corresponding component of the list 'Rstats' should be an R function that outputs a list with components 'statistic' (value of the test statistic), 'pvalue' (pvalue of the test; if not computable should be set to 0), 'decision' (1 if we reject the null, 0 otherwise), 'alter' (see above), 'stat.pars' (see above), 'pvalcomp' (1L if the pvalue can be computed, 0L otherwise), 'nbparstat' (length of stat.pars). If the value of 'stat' is not 0, then the corresponding component of 'Rstats' should be set to 'NULL'. |
center |
Logical. Should we center the data generated |
scale |
Logical. Should we center the data generated |
pvalcomp |
Integer. |
Details
This version is faster (but maybe less easy to
use in the process of investigating the power of test statistics under
different alternatives) than the powcomp.easy
version.
Value
A list of class power
whose components are described below:
M |
number of Monte Carlo repetitions. |
law.indices |
vector of law indices as given by function |
vectn |
vector of sample sizes. |
stat.indices |
vector of test statistic indices as given by function |
decision |
a vector of counts (between 0 and
where |
levels |
vector of levels for the test. |
cL |
left critical values used. |
cR |
right critical values used. |
usecrit |
a vector of 1s and 0s depending if a critical value has been used or not. |
alter |
type of each one of the tests in |
nbparlaws |
default number of parameters used for each law in |
parlaws |
default values of the parameters for each law. |
nbparstats |
default number of parameters for each test
statistic in |
parstats |
default values of the parameters for each test statistic. |
nbclus |
number of CPUs used for the simulations. |
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
## Regenerate Table 6 from Puig (2000) (page 424)
law.index <- 1
# Take M = 50000 for accurate results
M <- 10
vectn <- c(10,15,20,35,50,75,100)
level <- c(0.05)
stat.indices <- c(43,44,42,45,46)
law.indices <- c(2,3,4)
alter <- list(stat43 = 3,stat44 = 3,stat42 = 3,stat45 = 3,stat46 = 3)
critval <- many.crit(law.index,stat.indices,M,vectn,level,alter,
law.pars = NULL,parstats = NULL)
table6 <- powcomp.fast(law.indices,stat.indices,vectn,M,level,critval = critval,alter,
parlaws = NULL,parstats = NULL,nbclus = 1)
table6