return_mmc: S3 class 'mmc'.

Description Usage Arguments Examples

Description

S3 class mmc.

Usage

1
2
return_mmc(S0, y, statistic, dgp, est, lower, upper, N, type, method,
  alpha, control, call, seed, lmc, opt_result, opt_trace)

Arguments

S0

An atomic vector. Value of the test statistic applied to the data.

y

A vector or data frame.

statistic

A function or a character string that specifies how the statistic is computed. The function needs to input the y and output a scalar.

dgp

A function. The function inputs the first argument y and a vector of nuisance parameters v and outputs a simulated y. It should represent the data generating process under the null. Default value is the function sample(y, replace = TRUE), i.e. the bootstrap resampling of y.

est

A vector with length of v. It is the starting point of the algorithm. If est is a consistent estimate of v then mmc will return both the MMC and Local Monte Carlo (LMC). Default is NULL, in which case, default values will be generated automatically.

lower

A vector with length of v. Lower bounds for nuisance parameters under the null. See Details.

upper

A vector with length of v. Upper bounds for nuisance parameters under the null. See Details.

N

An atomic vector. Number of replications of the test statistic.

type

A character string. It specifies the type of test the p-value function produces. The possible values are geq, leq, absolute and two-tailed. Default is geq.

method

A character string. Type of algorithm to be used for global optimization. The four available methods are simulated annealing (GenSA), particle swarm (pso), genetic algorithm (GA), and grid search (gridSearch) Default is GenSA,

alpha

An atomic vector. If mmc finds a p-value over alpha, then the algorithm will stop. This is particularly useful if we are only looking at testing a hypothesis at a particular level. Default is NULL.

control

A list. Arguments to be used to control the behavior of the algorithm chosen in method. See controls section for more details.

call

An object of class call. Original call to mmc

seed

An integer vector. Value of .Random.seed at the start of mmc call.

lmc

An object of class mc. If par is specified, it returns an object of class mc corresponding the Local Monte Carlo test.

opt_result

An object returning the optimization results.

opt_trace

An object returning the optimization results.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# Generate typical data found inside the function mmc()
S0 <-  0
y <-  rnorm(100)
statistic <-  function(y, v) mean(y) * v
dgp <-  function(y, v) sample(y, replace = TRUE)
est <- 1
lower <- -1
upper <- 1
N <-  99
type <-  "geq"
method <- "GenSA"
alpha <- 0.05
control <- MaxMC:::get_control(method)
call <- call("mc",y= y, statistic = statistic, dgp = dgp, N = 99, type = type)
seed <-  NULL
lmc <- list(pval = 0.10)
pval <-  0.65
opt_result <- list(value = 0.10)
opt_trace  <- as.data.frame(matrix(data = NA, control$maxit, 3,
                                   dimnames = list(NULL,c("ite","pval","max"))))

# Combine data and return it as an object of class 'mmc'
MaxMC:::return_mmc(S0 = S0, y = y, statistic = statistic, dgp = dgp, est = est, lower = lower,
                   upper = upper, N = N, type = type, method = method, alpha = alpha,
                   control = control, call = call, seed = seed, lmc = lmc,
                   opt_result = opt_result, opt_trace = opt_trace)

julienneves/maxMC documentation built on May 10, 2019, 3:18 a.m.