boot
function in the
package also called boot
. Whereas boot
is very general and therefore
has many arguments, the Boot
function has very few arguments, but should
meet the needs of many users.## S3 method for class 'default':
Boot(object, f=coef, labels=names(coef(object)),
R=999, method=c("case", "residual"))
## S3 method for class 'lm':
Boot(object, f=coef, labels=names(coef(object)),
R=999, method=c("case", "residual"))
## S3 method for class 'glm':
Boot(object, f=coef, labels=names(coef(object)),
R=999, method=c("case", "residual"))
## S3 method for class 'nls':
Boot(object, f=coef, labels=names(coef(object)),
R=999, method=c("case", "residual"))
lm
, glm
or nls
. The function may work with other regression objects that support the update
method and have a subset
argumentcoef
, to return to
regression coefficient estimates. For example,f
. If
this argument is of the wrong length, then generic labels will be generated.lm
or glm
model is different in the bootstrap lm
and nls
objects and will reboot
for the returned value from this function. The car
package includes additional generic functions summary, confint and hist that works
with boot objects.boot
function is
very general, Boot
is very specific. It takes the information from a
regression object and the choice of method
, and creates a function that is
passed as the statistic
argument to boot
. The argument R
is also passed to boot
. All other arguments to boot
are
kept at their default values.
The methods available for lm
and nls
objects are nls
objects ordinary residuals are used
in the resampling rather than the standardized residuals used in the lm
method. The residual bootstrap for
generalized linear models has several competing approaches, but none are
without problems. If you want to do a residual bootstrap for a glm, you
will need to write your own call to boot
.
An attempt to model fit to a bootstrap sample may fail. In a lm
or
glm
fit, the bootstrap sample could have a different rank from the original
fit. In an nls
fit, convergence may not be obtained for some bootstraps.
In either case, NA
are returned for the value of the function f
.
The summary methods handle the NA
s appropriately.Boot
objects from the boot
package are
boot.array
,
boot.ci
,
plot.boot
and
empinf
. Additional
functions in the car
package are
summary.boot
,
confint.boot
, and
hist.boot
.m1 <- lm(Fertility ~ ., swiss)
betahat.boot <- Boot(m1, R=199) # 199 bootstrap samples--too small to be useful
summary(betahat.boot) # default summary
confint(betahat.boot)
hist(betahat.boot)
# Bootstrap for the estimated residual standard deviation:
sigmahat.boot <- Boot(m1, R=199, f=sigmaHat, labels="sigmaHat")
summary(sigmahat.boot)
confint(sigmahat.boot)
Run the code above in your browser using DataLab