Learn R Programming

moonboot (version 1.0.1)

shorth: Mean of the Shorthest Half

Description

Calculates the mean of the data points in the shortest interval containing half of the data. The arguments of the function are such that it directly can be used as a statistic in the mboot() function.

Usage

shorth(data, indices = NULL)

Value

The mean of the data points in the shortest interval containing half of the data.

Arguments

data

the data as a numeric vector.

indices

the selected indices of data, by default seq_along(data).

References

Andrews D.F. et al. (1972) Robust Estimates of Location Princeton University Press, Princeton.

Examples

Run this code
data <- rnorm(100)
shorth(data)
shorth(data, sample(1:100, size = 20))

# Calculating a CI for shorth using [mboot()]
data <- rnorm(100)
boot.out <- mboot(data, shorth, m = sqrt(length(data)))
basic.ci <- mboot.ci(boot.out, conf =0.95, tau = function(n) return(n^(1/3)), types = "basic")$basic

Run the code above in your browser using DataLab