test_simul: 'test_simul' is used to conduct a simulation which compare...

Description Usage Arguments Value Examples

View source: R/simul_fn.R

Description

test_simul is used to conduct a simulation which compare the sample size and detection rates of sequential GLR-lik, discrete mixture test and a fixed sample size test based on the sample mean.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
test_simul(
  mu_target,
  mu_true = mu_target,
  mu_0,
  alpha = 0.1,
  beta = 0.1,
  B = 100,
  print_progress = TRUE,
  print_result = FALSE,
  sample_generator = G_sample,
  power_fn = G_pwr,
  fixed_test_fn = z_test,
  seq_test_fn = seq_G_test_generator
)

Arguments

mu_target

The boundary of the target alternative hypothesis space.

mu_true

The underlying mean of the data-generating distribution (default = mu_target).

mu_0

The boundary of the null hypothesis space.

alpha

The upper bound of the type-I error (default = 0.1)

beta

The upper bound of the type-II error (default = 0.1).

B

The number of the repeats of the simulation (default = 100).

print_progress

A logical value. If print_progress = TRUE, a progress bar of the simulation will be printed (default = TRUE).

print_result

A logical value. If print_result = TRUE, A short summary of the simulation result will be presented (default = FALSE).

sample_generator

R function to generate i.i.d. random samples. The function must take the number of samples n and the underlying mean mu_true as inputs.

power_fn

R function to compute the power of the test given the sample size. The function must take the number of samples n, the boundary of the alternative space mu_target, the boundary of the null space mu_0, and type-I error bound alpha.

fixed_test_fn

R function to conduct a fixed sample size test. The function must take the sample mean x_bar, the number of sample n, The boundary of the null space mu_0, and the type-I error bound alpha. The function must return a positive numeric value if the test reject the null.

seq_test_fn

R function to conduct sequential GLR-like and discrete mixture tests. The function must take the type-I error bound alpha, the upper bound nmax and the lower bound nmin of the target interval.

Value

A list of simulation results and underlying settings.

reject_rate

Estimated probabilities of rejecting the null hypothesis.

sample_size

Estimated average sample sizes of testing procedures.

early_stop_ratio

Estimated probabilities of tests being stopped earlier than the fixed sample size test.

reject_list

A list of vectors representing whether each test reject the null (1) or not (0) for each simulation run.

sample_size_list

A list of numbers of samples used in each test.

mu_target

The boundary of the target alternative hypothesis space.

mu_true

The underlying mean of the data-generating distribution.

mu_0

The boundary of the null hypothesis space.

alpha

The upper bound of the type-I error.

beta

The upper bound of the type-II error.

Examples

1
# For the example of the simulation, please check https://github.com/shinjaehyeok/SGLRT_paper.

shinjaehyeok/SGLRT_paper documentation built on Oct. 25, 2020, 8:11 a.m.