You are on page 1of 1

dua_sample=function(z,y,k) { meanz=NULL meany=NULL tethas=NULL n1=length(z) n2=length(y) bootz=replicate(k,sample(z,replace=TRUE,size=n1)) booty=replicate(k,sample(y,replace=TRUE,size=n2)) for (i in 1:k) { meanz[i]=mean(bootz[,i]) meany[i]=mean(booty[,i]) tethas[i]=meanz[i]-meany[i] } hitung=function(p,q) { m=0

for (i in 1:k) { if (p[i]<=q) { m=m+1 } if (p[i]>q) { m=m } } m } jumlah=hitung(tethas,0) persen=jumlah/k se=sqrt(var(tethas)) tetha=mean(z)-mean(y) apa=tetha/se cat("tetha: \n",tetha,"\n") cat("tetha bootstrap: \n") print(tethas) cat("standar error bootstrap: \n",se,"\n") cat("standar error above zero: \n",apa,"\n") cat("P-Value: \n",persen,"\n") hist(tethas,breaks=20) }

You might also like