θ=P(X<Y)
XY
정의에 의하면
θ=P(X<Y)=∫∞−∞FX(y)fY(y)dy,
FXXfYYXYFXfYθ
θ^=∫∞−∞F^X(y)f^Y(y)dy.
이것은 가우스 커널을 사용하여 다음 R 코드에서 구현됩니다.
# Optimal bandwidth
h = function(x){
n = length(x)
return((4*sqrt(var(x))^5/(3*n))^(1/5))
}
# Kernel estimators of the density and the distribution
kg = function(x,data){
hb = h(data)
k = r = length(x)
for(i in 1:k) r[i] = mean(dnorm((x[i]-data)/hb))/hb
return(r )
}
KG = function(x,data){
hb = h(data)
k = r = length(x)
for(i in 1:k) r[i] = mean(pnorm((x[i]-data)/hb))
return(r )
}
# Baklizi and Eidous (2006) estimator
nonpest = function(dat1B,dat2B){
return( as.numeric(integrate(function(x) KG(x,dat1B)*kg(x,dat2B),-Inf,Inf)$value))
}
# Example when X and Y are Cauchy
datx = rcauchy(100,0,1)
daty = rcauchy(100,0,1)
nonpest(datx,daty)
θ
# bootstrap
B=1000
p = rep(0,B)
for(j in 1:B){
dat1 = sample(datx,length(datx),replace=T)
dat2 = sample(daty,length(daty),replace=T)
p[j] = nonpest(dat1,dat2)
}
# histogram of the bootstrap sample
hist(p)
# A confidence interval (quantile type)
c(quantile(p,0.025),quantile(p,0.975))
다른 종류 의 부트 스트랩 간격도 고려 될 수 있습니다.