

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!


1
2
3
Usage:
boot(data, statistic, R, sim="ordinary", stype="i", strata=rep(1,n), L=NULL, m=0, weights=NULL, ran.gen=function(d, p) d, mle=NULL, ...)
sim: A character string indicating the type of simulation required. Possible values are ’"ordinary"’ (the default), ’"parametric"’, ’"balanced"’, ’"permutation"’, or ’"antithetic"’. Importance resampling is specified by including importance weights; the type of importance resampling must still be specified but may only be ’"ordinary"’ or ’"balanced"’ in this case. ran.gen: This function is used only when ’sim’ is ’"parametric"’ when it describes how random values are to be generated. It should be a function of two arguments. The first argument should be the observed data and the second argument consists of any other information needed (e.g. parameter estimates). The second argument may be a list, allowing any number of items to be passed to ’ran.gen’. The returned value should be a simulated data set of the same form as the observed data which will be passed to statistic to get a bootstrap replicate. It is important that the returned value be of the same shape and type as the original dataset. If ’ran.gen’ is not specified, the default is a function which returns the original ’data’ in which case all simulation should be included as part of ’statistic’. Use of ’sim="parametric"’ with a suitable ’ran.gen’ allows the user to implement any types of nonparametric resampling which are not supported directly.
4
mle: The second argument to be passed to ’ran.gen’. Typically these will be maximum likelihood estimates of the parameters. For efficiency ’mle’ is often a list containing all of the objects needed by ’ran.gen’ which can be calculated using the original data set only.
5
x <- rcauchy(25)
trimmed.mean <- function(x) {mean(x, trim=0.25) }
ran.gen.normal <- function(d,p) { rnorm( length(d), mean = p$xbar, sd = p$s) }
boot.normal.out <- boot( data = x, statistic = trimmed.mean, R=999, sim="parametric", ran.gen = ran.gen.normal, mle = list( xbar = mean(x), sd = sqrt(var(x))) )
boot.normal.out
PARAMETRIC BOOTSTRAP
Call: boot(data = x, statistic = stat.cauchy, R = 999, sim = "parametric", ran.gen = ran.gen.normal, mle = list(xbar = mean(x), s = sqrt(var(x))))
Bootstrap Statistics : original bias std. error
6
t1* -0.1694276 0.1512959 0.
hist(boot.normal.out$t)
7
ran.gen.cauchy <- function(d, p ) { rcauchy(length(d), location = p$med, scale = p$sc) }
boot.cauchy.out <-boot(data=x, statistic=trimmed.mean, R=999, sim="parametric",ran.gen = ran.gen.cauchy, mle = list( med = median(x), sc = IQR(x)/2) )