ScPoEcon / ScPoEconometrics

Undergraduate textbook for Econometrics with R
https://ScPoEcon.github.io/ScPoEconometrics/
Other
142 stars 68 forks source link

explain inference with boot strap and not null-hypothesis testing #137

Closed floswald closed 4 years ago

floswald commented 5 years ago
floswald commented 5 years ago
library(dplyr)
new_cars = sample_n(cars, size = nrow(cars), replace = TRUE)
b1 = coef(lm(speed ~ dist, new_cars))[2]

boostrap

library(bootstrap)
fc = function(d,i){
d2 = d[i, ]
return(coef(lm(speed ~ dist,data = d2))[2])
}
bootcars <- boot(cars, fc, R=500)
plot(bootcars)

relate to testing against zero