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.
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)
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).
index of the distribution from which to generate
observations used to compute the values of the test statistics specified with stat.indices
.
integer. Size of the samples from which to compute the value of the test statistics.
integer. Number of Monte-Carlo repetitions. Only used when method
= 'MC'.
integer. Number of \(p\)-values to compute for each test statistic.
integer value in 0,1,2,3,4. Type of test. See function create.alter
.
vector of the parameter values for the law specified in law.index
.
named-list of vectors of parameters for the test statistics specified in
stat.indices
. The names of the list should be stat
\(xxx\) where \(xxx\)
are the indices specified in stat.indices
.
used only if method
= 'MC'. Integer value (as given by
function getindex
) specifying the distribution under
the null hypothesis.
vector of parameters for the null distribution
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
).
If 'law.index' is set to 0 then 'Rlaw.index' should be a (random generating) function.
If 'null.dist' is set to 0 then 'Rnull.dist' should be a (random generating) function.
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
.
Logical. Should we center the data generated
Logical. Should we center the data generated
the N
x length(stat.indices
) matrix of \(p\)-values.
same as input.
same as input.
same as input.
same as input.
same as input.
same as input.
same as input.
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
# NOT RUN {
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")
# }
Run the code above in your browser using DataLab