Learn R Programming

modelr (version 0.1.1)

bootstrap: Generate n bootstrap replicates.

Description

Generate n bootstrap replicates.

Usage

bootstrap(data, n, id = ".id")

Arguments

data

A data frame

n

Number of bootstrap replicates to generate

id

Name of variable that gives each model a unique integer id.

Value

A data frame with n rows and one column: strap

Examples

Run this code
# NOT RUN {
library(purrr)
boot <- bootstrap(mtcars, 100)

models <- map(boot$strap, ~ lm(mpg ~ wt, data = .))
tidied <- map_df(models, broom::tidy, .id = "id")

hist(subset(tidied, term == "wt")$estimate)
hist(subset(tidied, term == "(Intercept)")$estimate)
# }

Run the code above in your browser using DataLab