正在加载图片...
library(bootstrap) #for the law data print (cor(law$LSAT,law$GPA)) #set up the bootstrap B<-200 #number of replicates n <-nrow(law) #sample size R <-numeric(B) #storage for replicates #bootstrap estimate of standard error of R for (b in 1:B){ #randomly select the indices i <-sample(1:n,size n,replace TRUE) LSAT <law$LSAT[i] #i is a vector of indices GPA <law$GPA[i] R[b]<cor(LSAT,GPA) } #output print(se.R <sd(R)) hist(R,prob TRUE) Code se()的Bootstrap估计为0.1371913,样本相关系数的标准差的理论值 Previous Next First Last Back Forward 8↑Code library(bootstrap) #for the law data print(cor(law$LSAT, law$GPA)) #set up the bootstrap B <- 200 #number of replicates n <- nrow(law) #sample size R <- numeric(B) #storage for replicates #bootstrap estimate of standard error of R for (b in 1:B) { #randomly select the indices i <- sample(1:n, size = n, replace = TRUE) LSAT <- law$LSAT[i] #i is a vector of indices GPA <- law$GPA[i] R[b] <- cor(LSAT, GPA) } #output print(se.R <- sd(R)) hist(R, prob = TRUE) ↓Code se(ˆτ)BootstrapOè0.1371913, É'XÍIO nÿä Previous Next First Last Back Forward 8
<<向上翻页向下翻页>>
©2008-现在 cucdc.com 高等教育资讯网 版权所有