Learn R Programming

moonboot (version 0.9.1)

shorth: Mean of the Shorthest Half

Description

Calculates the mean of the data points in the shortest interval containing half of the data. This function is ready to be used as a statistic in 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 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