Search code examples
rstatistics-bootstraphypothesis-testrobust

Bootstrap-t Method for Comparing Trimmed Means in R


I am confused with different robust methods to compare independent means. I found good explanation in statistical textbooks. For example yuen() in case of equal sample sizes. My samples are rather unequal, thus I would like to try a bootstrap-t method (from Wilcox book: Introduction to Robust Estimation and Hypothesis Testing, p.163). It says yuenbt() would be a possible solution.

But all textbooks say I can use vectors here:

yuenbt(x,y,tr=0.2,alpha=0.05,nboot=599,side=F)

If I check the local description it says:

yuenbt(formula, data, tr = 0.2, nboot = 599)

What's wrong with my trial:

x <- c(1,2,3)
y <- c(5,6,12,30,2,2,3,65)
yuenbt(x,y)

Why can't I use yuenbt-function with my two vectors? Thank you very much


Solution

  • Looking at the help (for those wondering, yuenbt is from the package WRS2...) for yuenbt, it takes a formula and a dataframe as arguments. My impression is that it expects data in long format.

    With your example data, we can achieve that like so:

    library(WRS2)
    
    x <- c(1,2,3)
    y <- c(5,6,12,30,2,2,3,65)
    
    dat <- data.frame(value=c(x,y),group=rep(c("x","y"), c(length(x),length(y))))
    

    We can then use the function:

    yuenbt(value~group, data=dat)