You are on page 1of 1

bootstrap = function(x,y,n,R)

{
N = length(x)
number = c(1:N)
korelasi = matrix(nrow=R, ncol=1)
for (i in 1:R)
{
sampel=sample(number,n)
xsampel = x[sampel]
ysampel = y[sampel]
korelasi[i]=cor(xsampel,ysampel)
}
korelasi=as.vector(korelasi)
mean_bootstrap = mean(korelasi)
sd_bootstrap = sd(korelasi)
hist(korelasi)

#n is number of sample, R is Replication

#provide space for rata


#doing sampling
# find the corelation of each sample

#create the histogram

list(mean_bootstrap = mean_bootstrap, sd_bootstrap = sd_bootstrap, korelasi=ko


relasi)
}

You might also like