gen_bst_df: Generate a data frame with estimate and bootstrap CIs.

gen_bst_dfR Documentation

Generate a data frame with estimate and bootstrap CIs.

Description

gen_bst_df is a function called that generates a data frame with confidence intervals of a continuous variable by levels of one or two categorical ones (factors).

Usage

gen_bst_df(object = NULL, formula = NULL, data = NULL, stat = "mean", ...)

Arguments

object

When chaining, this holds an object produced in the earlier portions of the chain. Most users can safely ignore this argument. See details and examples.

formula

A formula with shape: y ~ x or y ~ x|z where y is a numerical variable and both x and z are factors.

data

A data frame where the variables in the formula can be found.

stat

Statistic used for bst.

...

Passes optional arguments to bst.

Value

A data frame with the confidence intervals by level.

Examples

data(kfm, package = "ISwR")
require(sjlabelled, quietly = TRUE)
kfm <- kfm |>
  var_labels(
    dl.milk = "Breast-milk intake (dl/day)",
    sex = "Sex",
    weight = "Child weight (kg)",
    ml.suppl = "Milk substitute (ml/day)",
    mat.weight = "Maternal weight (kg)",
    mat.height = "Maternal height (cm)"
  )

kfm |>
  gen_bst_df(dl.milk ~ sex)

data(birthwt, package = "MASS")
require(dplyr, quietly = TRUE)
birthwt <- mutate(birthwt,
  smoke = factor(smoke, labels = c("Non-smoker", "Smoker")),
  Race = factor(race > 1, labels = c("White", "Non-white"))
)

birthwt <- birthwt |>
  var_labels(
    bwt = "Birth weight (g)",
    smoke = "Smoking status"
  )

gen_bst_df(bwt ~ smoke | Race, data = birthwt)

pubh documentation built on Oct. 8, 2024, 9:08 a.m.