powcomp-fast: Computation of power and level tables for hypothesis tests.

Description Usage Arguments Details Value Author(s) References Examples

Description

Functions for the computation of power and level tables for hypothesis tests, with possible use of a cluster.

Usage

1
2
3
4
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)

Arguments

law.indices

vector of law indices as given by function getindex.

stat.indices

vector of statistic indices as given by function getindex (some components can be 0 if you want to use your own function for some test statistics; see 'Rstats' argument).

vectn

vector of sample sizes (n) values.

M

number of Monte Carlo repetitions.

levels

vector of significance levels for the test.

critval

if not NULL, a named-list of critical values for each test statistic. The names of the list should be statj, j taken in stat.indices. Note that if a single value of critval$statj is povided, then it is the right critical value. If two values are provided, then these are the left and right critical values, in that order. If NULL, critval is computed using the function many.crit; in that case, be sure to provide the correct value for null.law.index.

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 statj, j taken in stat.indices.

parlaws

named-list of parameter values for each law to simulate. The names of the list should be lawj, j taken in law.indices. The length of vector lawj should not be greater than 4 (we supposed than no common distribution has more than 4 parameters!).

parstats

named-list of parameter values for each statistic to simulate. The names of the list should be statj, j taken in stat.indices (in the same order). If NULL, the default parameter values for these statistics will be used.

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, no model is used. If an integer i>0, the model coded in the C function modelei is used. Else this shoud be an R function that takes three arguments: eps (vector of ε values), thetavec (vector of θ values) and xvec (vector or matrix of x values). This function should take a vector of errors, generate observations from a model (with parameters thetavec and values xvec) based on these errors, then compute and return the residuals from the model. See function modele1.R in directory inst/doc/ for an example in multiple linear regression.

null.law.index

index of the law under the null. Only used, by many.crit function, if critval is NULL.

null.law.pars

vector of parameters corresponding to null.law.index.

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

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 getindex.

vectn

vector of sample sizes.

stat.indices

vector of test statistic indices as given by function getindex.

decision

a vector of counts (between 0 and M) of the decisions taken for each one of the levels.len * laws.len * vectn.len * stats.len combinations of (level,law,sample size,test statistic), to be understood in the following sense. The decision for the l-th level (in levels), d-th law (in law.indices), n-th sample size (in vectn) and s-th test statistic (in stat.indices) is given by:

decision[s + stats.len*(n-1) + stats.len*vectn.len*(d-1) + stats.len*vectn.len*laws.len*(l-1)]

where stats.len, vectn.len, laws.len and levels.len are respectively the lengths of the vectors stat.indices, vectn, law.indices and levels.

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 stat.indices used (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).

nbparlaws

default number of parameters used for each law in law.indices.

parlaws

default values of the parameters for each law.

nbparstats

default number of parameters for each test statistic in stat.indices.

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

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
## 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

Example output

Loading required package: parallel
Loading required package: Rcpp
                      law   n level W^2 U^2 A^2 sqrt{n}D   V
1    Normal(mu=0,sigma=1)  10  0.05  10   0  10        0  10
2                          15  0.05  60  20  40       50  30
3                          20  0.05   0  30  10        0  20
4                          35  0.05  40  50  20       40  30
5                          50  0.05  50  50  20       30  50
6                          75  0.05  30  60  30       40  30
7                         100  0.05  50  60  70       60  40
8    Cauchy(mu=0,sigma=1)  10  0.05  30  30  30       30  30
9                          15  0.05  70  40  70       70  50
10                         20  0.05  40  70  30       50  50
11                         35  0.05  40  90  50       40  50
12                         50  0.05  70  90  80       70  90
13                         75  0.05  80  90 100       80  90
14                        100  0.05 100 100 100       90 100
15 Logistic(mu=0,sigma=1)  10  0.05  10  20  10       10  10
16                         15  0.05  30  30  40       40  40
17                         20  0.05  10  30  10       10  10
18                         35  0.05  20  40  20       20   0
19                         50  0.05  20  30  10       20  40
20                         75  0.05   0   0   0        0   0
21                        100  0.05   0   0   0        0   0
                n level    W^2    U^2    A^2 sqrt{n}D      V
Average power  10  0.05 16.667 16.667 16.667   13.333 16.667
2              15  0.05 53.333 30.000 50.000   53.333 40.000
3              20  0.05 16.667 43.333 16.667   20.000 26.667
4              35  0.05 33.333 60.000 30.000   33.333 26.667
5              50  0.05 46.667 56.667 36.667   40.000 60.000
6              75  0.05 36.667 50.000 43.333   40.000 40.000
7             100  0.05 50.000 53.333 56.667   50.000 46.667
              n level    W^2    U^2    A^2 sqrt{n}D      V
Average gap  10  0.05  3.333  3.333  3.333    6.667  3.333
2            15  0.05  3.333 26.667  6.667    3.333 16.667
3            20  0.05 26.667  0.000 26.667   23.333 16.667
4            35  0.05 26.667  0.000 30.000   26.667 33.333
5            50  0.05 13.333  3.333 23.333   20.000  0.000
6            75  0.05 16.667  3.333 10.000   13.333 13.333
7           100  0.05  6.667  3.333  0.000    6.667 10.000
            n level W^2 U^2 A^2 sqrt{n}D  V
Worst gap  10  0.05  10  10  10       10 10
2          15  0.05  10  40  20       10 30
3          20  0.05  30   0  40       30 20
4          35  0.05  50   0  40       50 40
5          50  0.05  20  10  30       20  0
6          75  0.05  30  10  30       20 30
7         100  0.05  20  10   0       10 30

PoweR documentation built on May 2, 2019, 2:09 p.m.

Related to powcomp-fast in PoweR...