当我使用
boot()
表示一系列回归系数时,我得到 Bootstrap 统计数据的显示,如下所示。 有没有办法以数据帧的形式检索这些 Bootstrap 统计信息?
bs<-function(formula, data, indices) {
d<-data[indices,]
fit1<-lm(formula,data=d)
r<-residuals(fit1)
taus<-c(0.1, 0.2, 0.3, 0.4, 0.5)
fit2<-rq(srs~r, tau=taus, data=d)
return(coef(fit2))
library(boot)
results<-boot(data=earli, statistic=bs, R=1000, formula=Freq~prepreg_bmi+mat_age)
results
Bootstrap Statistics :
original bias std. error
t1* 39.000000 -0.06213177 0.4923311
t2* 0.000000 0.81613987 0.9480617
t3* 39.994080 0.20734506 0.5515006
t4* 1.978584 -0.27895713 1.0157747
t5* 41.494479 0.08356320 0.6923510
t6* 2.982711 -0.28310189 1.2957767
t7* 43.464062 -0.22307964 0.7879350
t8* 3.075496 0.31197213 1.4150300
t9* 44.974168 0.03526846 0.8638345
t10* 3.978100 -0.53116587 1.5490870
我尝试了
results$t0
,但这只给了我数据框中的截距和系数。如果包含标准误差值的系数表在
results$...
中不可用,您可以使用 capture.output()
打印 results
的系数表,然后从那里对该表进行子集化。但您可能需要重命名列。
这可能有效:
out <- capture.output(results)
n <- length(out)
tab <- read.table(text =out[10:n], header = TRUE)
colnames(tab) = c("t", "original", "bias", "std.error")
tab