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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started