simulation_mc: Monte Carlo Simulation

View source: R/simulation.R

simulation_mcR Documentation

Monte Carlo Simulation

Description

Generates N Monte Carlo replicates of a statistic.

Usage

simulation_mc(y, statistic, dgp = function(y) sample(y, replace = TRUE),
  N = 99, ...)

Arguments

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 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.

N

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

...

Other named arguments for statistic which are passed unchanged each time it is called

Value

The vector of replication of test statistic.

Examples

# Generate some data
y = rnorm(10)

# Specify statistic and DGP
statistic = function(x) mean(x)
dgp = function(y, v) sample(y, replace = TRUE)

# Simulate statistic N times
MaxMC:::simulation_mc(y, statistic = statistic, dgp = dgp, N = 99)


julienneves/MMC documentation built on June 28, 2024, 1:34 p.m.