monte_carlo_sim: Monte-Carlo simulation

Description Usage Arguments Details Examples

View source: R/ts_bootstrap.R

Description

Method to evaluate the distribution of a statistic, dependent on the distribution of the data. Returns B samples from the distribution of the statistic.

Usage

1
monte_carlo_sim(sim.fn, statistic, B, sim.length, ...)

Arguments

sim.fn

Simulation function (distribution) from which the time series is drawn from. Takes only one argument representing the length of the drawn sample

statistic

Function: the statistic for which a sample-distribution will be created.

B

Amount of samples.

sim.length

Length of the sampled series.

...

Additional values passed on to the statistic function.

Details

Equal to drawing samples from the theoretical distribution of the statistic given the distribution of the data. This is useful when the theoretical distribution of the statistic, given the data distribution, does not have an analytical solution or to save time by computing an empirical distribution rather than calculating the theoretical.

Can for example be used to evaluate other bootstrap methods accuracy in a simulation study.

Examples

1
2
3
4
5
6
arima_sim <- function(n){arima.sim(model=list(ar=c(0.6, -0.4)), n=n)}
mcs.res <- monte_carlo_sim(series, mean, 5)

series <- arima_sim(100)
ars.res <- ARsieve_bootstrap(series, mean, B=500)
boxplot(cbind(mcs.res, ars.res))

rwigren/TSAutils documentation built on Nov. 5, 2019, 5:10 a.m.