knitr::opts_chunk$set( collapse = TRUE, comment = "#>" ) library(strop)
At the core of strop
is the bootstrap
function. This is a generic function with a default method (for one-dimensional data) and a method for data frames (two-dimensional data). This function is a constructor for an object of class strop
, which can be used in the package's other provided functions.
Single-valued bootstrapping is straightforward: the default function used by bootstrap
is mean
.
data(mtcars) bootstrap(mtcars$hp)$pop
Both the data frame and default constructors may be used with multivalued functions.
cen <- function(x) list(mean = mean(x), median = median(x)) bootstrap(mtcars$hp, cen)$pop
strop
provides a quantile.strop
function for calculating quantiles based on the bootstrap procedure. This function simply delegates to quantile(obj$stats)
.
quantile(bootstrap(mtcars$hp), c(0.05, 0.95))
strop
exposes a confint.strop
function for calculating central confidence intervals based on the bootstrap procedure.
confint(bootstrap(mtcars$hp, n = 100))
strop
provides a print.strop
function for assessing the results of bootstrap iteration. The function call, (original) sample estimates, and the beginning of the list of bootstrap estimates are printed.
print(bootstrap(mtcars$hp, n = 100))
strop
provides plot.strop
function to visualize the results of a bootstrap application. A histogram of each statistic is plotted for multi-valued bootstrapping, and central confidence intervals are indicated on each plot.
plot(bootstrap(mtcars$hp, n = 100))
strop
provides a convenience function for multiple linear regression analysis using the bootstrap procedure: mlrboot
. Given a fitted model object, mlrboot
produces a bootstrap object for the estimation of model coefficients.
fit <- lm(hp ~ ., data = mtcars) boot <- mlrboot(fit) print(boot, max = 5) plot(boot, vars = c("cyl", "wt"))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.