R/BCI.R

BCI <-
function(Z,Zr,ab=NULL,abH,B,level){
	p=ncol(Z)
	n=nrow(Z)
#	abhat.v=rep(NA,B) # save MLEs of a*b in the B bootstrap samples
	abhatH.v=matrix(NA,B)
	Index.m=matrix(NA,n,B)
	
	t1=0
	t2=0	
    for(i in 1:B){
	    U=runif(n,min=1,max=n+1)
       index=floor(U)	
		Index.m[,i]=index
		#H(.05)
		Zrb=Zr[index,]
		SH=MeanCov(Zrb)$S
		thetaH=MLEst(SH)
		abhatH=thetaH[1]*thetaH[2]	
		abhatH.v[i]=abhatH
		if (abhatH<abH){
			t2=t2+1	
		}
		
	 } # end of B loop
	
	abhatH.v=abhatH.v[!is.na(abhatH.v)]
	SEBH=sd(abhatH.v)
	
	# bootstrap confidence intervals using robust method
	CI2 =BpBCa(Zr,abhatH.v,t2,level)
#    Results=list(CI=CI2)
    Results=list(CI=CI2[[1]],pv=CI2[[2]])
 	return(Results)
	
}
musto101/wilcox_R documentation built on May 23, 2019, 10:52 a.m.