many.pval: Computes several p-values for many test statistics.

Description Usage Arguments Value Author(s) References See Also Examples

Description

This function generates a sample of n observations from the law specified in law.index. It then computes the value of each test statistic specified in stat.indices and use it to obtain the corresponding p-value under the null. The computation of these p-values can be done using a Monte-Carlo simulation.

Usage

1
2
3
4
many.pval(stat.indices, law.index, n = 100, M = 10^5, N = 100,
          alter = create.alter(stat.indices), law.pars = NULL, parstats = NULL,
          null.dist = 2, null.pars = NULL, method = c("direct", "MC"), Rlaw.index = NULL,
Rnull.dist = NULL, Rstats = NULL, center=FALSE, scale=FALSE)

Arguments

stat.indices

vector of test 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).

law.index

index of the distribution from which to generate observations used to compute the values of the test statistics specified with stat.indices.

n

integer. Size of the samples from which to compute the value of the test statistics.

M

integer. Number of Monte-Carlo repetitions. Only used when method = 'MC'.

N

integer. Number of p-values to compute for each test statistic.

alter

integer value in 0,1,2,3,4. Type of test. See function create.alter.

law.pars

vector of the parameter values for the law specified in law.index.

parstats

named-list of vectors of parameters for the test statistics specified in stat.indices. The names of the list should be statxxx where xxx are the indices specified in stat.indices.

null.dist

used only if method = 'MC'. Integer value (as given by function getindex) specifying the distribution under the null hypothesis.

null.pars

vector of parameters for the null distribution

method

character. Either 'direct' to compute the p-value under the null using for example the asymptotic distribution of the test statistic under the null. This is not possible for all test statistics; or 'MC' to use a Monte-Carlo simulation to approximate the distribution of the test statistic under the null (specified by null.dist).

Rlaw.index

If 'law.index' is set to 0 then 'Rlaw.index' should be a (random generating) function.

Rnull.dist

If 'null.dist' is set to 0 then 'Rnull.dist' should be a (random generating) function.

Rstats

A list of same length as stat.indices. If a value of the vector stat.indices 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 a value of stat.indices 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

Value

pvals

the N x length(stat.indices) matrix of p-values.

stat.indices

same as input.

n

same as input.

M

same as input.

alter

same as input.

parstats

same as input.

null.dist

same as input.

method

same as input.

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

See Also

See calcFx, graph.

Examples

1
2
3
4
5
6
7
stind <- c(43,44,42)   # Indices of test statistics.
alter <-list(stat43=3,stat44=3,stat42=3) # Type for each test.
# Several p-values computed under the null.
# You can increase the values of M and N for better results.
matrix.pval <- many.pval(stat.indices=stind,law.index=1,
                        n=100,M=10,N=10,alter=alter,null.dist=1,
                        method="direct")

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

Related to many.pval in PoweR...