我想使用R中的库'boot'保存并稍后使用回归模型的自举回归系数。在下面的示例中,我希望能够查看并使用'wt'的1,000个自举系数。有办法吗?
library(boot)
set.seed(6967) # Make the results reproducible
bs <- function(formula, data, indices) {
d <- data[indices, ]
fit <- lm(formula, data=d)
return(coef(fit))
}
results <- boot(data=mtcars, statistic=bs, R=1000, formula=mpg~wt+disp)
results
ORDINARY NONPARAMETRIC BOOTSTRAP
Call:
boot(data = mtcars, statistic = bs, R = 1000, formula = mpg ~
wt + disp)
Bootstrap Statistics :
original bias std. error
t1* 34.96055404 -0.0095950965 2.596330855
t2* -3.35082533 -0.0139963846 1.141259963
t3* -0.01772474 -0.0002011716 0.008307083