simulation: Generate simulation data used in the paper and vignettes

Description Usage Arguments Details Examples

Description

simulation_data_1D generates one-dimensional data, simulation_data_2D generates two-dimensional image data.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
simulation_data_1D(
  n_points,
  n_obs = 100,
  mu_type = c("step", "sine", "custom"),
  cov_type = c("AR", "exponential", "matern", "any", "iid"),
  custom = NULL,
  corrupt = FALSE,
  ...
)

simulation_data_2D(n_obs = 100, corrupt = FALSE, rho = 0.3, ...)

simulate_1D(
  generator,
  snr = 0.2,
  block_sizes = 21,
  initial_filter = 0.9,
  alpha = 0.05,
  bandwidth = 90
)

Arguments

n_points

number of hypotheses, less equal than 1000

n_obs

number of observations to generate

mu_type

underlying function type, choices are 'sine', 'step', and 'custom'

cov_type

covariance type, choices are 'AR', 'exponential', 'matern', 'any' (arbitrary dependence), and 'iid' (independent)

custom

function to generate mean function if mu_type="custom"

corrupt

whether to use corruption model to generate data instead of addition model

...

passed to internal function; see 'Details'

rho

for two-dimensional simulation only, the correlation between adjacent locations

generator

list items returned by simulation_data_1D

snr

positive number to control the signal-to-noise ratio

block_sizes

integer vectors to control the block size; see focr

initial_filter, bandwidth

used by LAWS and SABHA; see focr, fdr-controls

alpha

'FOCR' and 'FDR' level; default is 0.05

Details

When mu_type is 'custom', parameter custom needs to be a function that takes 1:n_points as input and spit out the underlying mean function.

When cov_type is 'AR', the auto-correlation of adjacent column will be 0.9; The cov_type="exponential" and cov_type="matern" share the same phi=0.01 (range parameter) but different kappa (smoothness parameter). If you wish to change the range or smoothness parameter, pass phi and kappa to ... (see 'Examples'). For 'any' cov_type, the underlying covariance will be generated from a real data with arbitrary dependence. For 'iid' cov_type, the errors are independent standard normal distributed.

By default, corrupt is false, then the generated data is an addition of underlying signal plus random noises. When corrupt is true, the underlying signal will be randomly corrupted for each observation. The amount of corrupted points follows a binomial distribution.

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
27
28
29
30
31
32
33
34
35
# -------------------- Basic usage ------------------------
generator <- simulation_data_1D(200, cov_type = 'matern')

# generate date with signal-to-noise ratio = 0.4
data <- generator$gen_data(snr = 0.4)

# Data is n_obs x n_points matrix
dim(data)

image(cor(data), main = 'Matern correlation')

# -------------------- Change Matern parameters ------------------------
# Control kappa/phi here
generator <- simulation_data_1D(200, cov_type = 'matern', kappa = 10)
data <- generator$gen_data(snr = 0.4)

image(cor(data), main = 'Smooth Matern correlation with kappa=10')

# -------------------- 2D data ------------------------
# generate a 2D triangle data
generator <- simulation_data_2D(cov_type = 'AR')
data <- generator$gen_data(snr = 0.6)

par(mfrow = c(1,2))
image(matrix(colMeans(data), 32), main = '2D sample mean')
image(matrix(generator$mu, 32), main = '2D underlying mean')

# -------------------- Simulation used by paper ----------
# might take a while to run
if(interactive()){
  generator <- simulation_data_1D(n_points = 1000, cov_type = 'AR')
  set.seed(1000)
  sim <- simulate_1D(generator, snr = 0.3)
  plot(sim)
}

dipterix/focr documentation built on Dec. 20, 2021, 12:03 a.m.