b2ci <-
function(x,y,alpha=.05,nboot=2000,est=bivar,...){
#
# Compute a bootstrap confidence interval for the
# the difference between any two parameters corresponding to
# independent groups.
# By default, biweight midvariances are compared.
# Setting est=mean, for example, will result in a percentile
# bootstrap confidence interval for the difference between means.
# The default number of bootstrap samples is nboot=399
#
x<-x[!is.na(x)] # Remove any missing values in x
y<-y[!is.na(y)] # Remove any missing values in y
set.seed(2) # set seed of random number generator so that
# results can be duplicated.
print("Taking bootstrap samples. Please wait.")
datax<-matrix(sample(x,size=length(x)*nboot,replace=T),nrow=nboot)
datay<-matrix(sample(y,size=length(y)*nboot,replace=T),nrow=nboot)
bvecx<-apply(datax,1,est,...)
bvecy<-apply(datay,1,est,...)
bvec<-sort(bvecx-bvecy)
low <- round((alpha/2) * nboot) + 1
up <- nboot - low
temp <- sum(bvec < 0)/nboot + sum(bvec == 0)/(2 * nboot)
sig.level <- 2 * (min(temp, 1 - temp))
list(ci = c(bvec[low], bvec[up]), p.value = sig.level)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.