Bootstraping for linear models
boot_lm(
object,
f = NULL,
R = 999,
psim = 2,
resid.type = c("resample", "normal", "wild"),
data = NULL,
verbose = TRUE,
...
)
object of class lm
function to be applied (and bootstrapped), default coef
number of bootstrap samples, default 999
simulation level for simulate_lm
either “resample”, “normal” or “wild”.
optional data argument (useful/needed when data are not in an available environment).
logical (default TRUE) whether to print message if model does not converge. (rare for linear models).
additional arguments to be passed to function boot
The residuals can either be generated by resampling with replacement (default), from a normal distribution (parameteric) or by changing their signs (wild). This last one is called “wild bootstrap”.
# \donttest{
require(car)
data(barley, package = "nlraa")
## Fit a linear model (quadratic)
fit.lm <- lm(yield ~ NF + I(NF^2), data = barley)
## Bootstrap coefficients by default
fit.lm.bt <- boot_lm(fit.lm)
## Compute confidence intervals
confint(fit.lm.bt, type = "perc")
## Visualize
hist(fit.lm.bt, 1, ci = "perc", main = "Intercept")
hist(fit.lm.bt, 2, ci = "perc", main = "NF term")
hist(fit.lm.bt, 3, ci = "perc", main = "I(NF^2) term")
# }
Run the code above in your browser using DataLab