boot_lm | R Documentation |
Bootstraping for linear models
boot_lm(
object,
f = NULL,
R = 999,
psim = 2,
resid.type = c("resample", "normal", "wild"),
data = NULL,
verbose = TRUE,
...
)
object |
object of class |
f |
function to be applied (and bootstrapped), default coef |
R |
number of bootstrap samples, default 999 |
psim |
simulation level for |
resid.type |
either “resample”, “normal” or “wild”. |
data |
optional data argument (useful/needed when data are not in an available environment). |
verbose |
logical (default TRUE) whether to print message if model does not converge. (rare for linear models). |
... |
additional arguments to be passed to function |
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”.
at the moment, when the argument data is used, it is not possible to check that it matches the original data used to fit the model. It will also override the fetching of data.
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")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.