Question: library(boot) #Customfunctiontofindcorrelation #betweenthePetalLengthandWidth corr.fun
library(boot)
#Customfunctiontofindcorrelation
#betweenthePetalLengthandWidth
corr.fun<-function(data,idx){
df<-data[idx,]
#Findthespearmancorrelationbetween
#the3rdand4thcolumnsofdataset
c(cor(df[,3],df[,4],method='spearman'))
}
#donotchangetheseed;usedforreproducability
set.seed(42)
#Performthebootstrapwith1000replicas
#results<-boot(data=iris,statistic=corr.fun,R=1000)
bootstrap<-boot(data=iris,statistic=corr.fun,R=1000)
#Displaytheresultsofthebootfunction
print(bootstrap)
#Displaythefullobservedvalueofthestatisticappliedtothedata
#original_value<-corr.fun(iris,1:nrow(iris))
#print(paste("Originalvalue:",original_value))
original_value<-bootstrap$t0
print(paste("Originalvalueofthestatistic:",original_value))
Using boot.ci, calculate the confidence interval using percentile bootstrap (type = "perc"). The variable bootstrap has been calculated for you but the calculation is hidden
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
