You are on page 1of 1

library(bootstrap)

theta<-max( eigen(cov(scor))$values)/sum( eigen(cov(scor))$values)


theta
B<-1000
sampling<-numeric(B)
for ( i in 1: B) {
indexes<-sample(1:88 , replace = TRUE)
boot<-scor[indexes,]
thetastar<- max( eigen(cov(boot))$values)/sum( eigen(cov(boot))$values)
sampling[i]<-thetastar }
SE_theta<- sd(sampling) #standard error of theta
SE_theta
mean(sampling)
hist(sampling)
abline(v=theta)
upper<-theta+1.96*SE_theta
lower<-theta-1.96*SE_theta
c(lower,upper) # 95% CI for theta

You might also like