Learn R Programming

groupcompare (version 1.0.1)

calchubermeandif: The difference between Huber's M-estimator of location

Description

Computes the difference between Huber's M-estimator of location of two groups in long data format.

Usage

calchubermeandif(x, indices, ...)

Value

A numeric value representing the difference between Huber's M-estimator of location of the two groups.

Arguments

x

A data frame or matrix containing the input data. The first column should be the variable of interest, and the second column should be the grouping variable.

indices

Optional; specific rows to be considered. If not provided, all rows are used.

...

Additional arguments passed to the internal hubermean function.

Author

Zeynel Cebeci, A. Firat Ozdemir, Engin Yildiztepe

Details

This function demonstrates the structure of a user-defined statistic function to use with bootstrap and permutation test. The function calculates the difference between Huber's M-estimator of location of two groups using the iterative weighted mean method. Huber's M-estimator of location is robust to outliers and is computed using an iterative re-weighting procedure. The internal function follows:

  • Initialize with the median of the data.

  • Compute weights based on deviations from the current mean.

  • Update the mean iteratively until convergence is reached.

See Also

Examples

Run this code
df <- data.frame(value = rnorm(100), group = rep(1:2, each = 50))
bivarplot(df)

# Bootstrap confidence intervals for the difference of 
# Huber's M-estimator of location of two groups
# Increase R for real-world applications
bshubermean <- bootstrap(df, statistic=calchubermeandif, alpha=0.05,
   alternative="less", R=200)
bshubermean

Run the code above in your browser using DataLab