estimate_proportion {esci}R Documentation

Estimates for a categorical variable with no grouping (single-group design)

Description

estimate_proportion is suitable for a single group design with a categorical outcome variable. It estimates the population proportion for the frequency of each level of the outcome variable, with confidence intervals. You can pass raw data or summary data.

Usage

estimate_proportion(
  data = NULL,
  outcome_variable = NULL,
  cases = NULL,
  case_label = 1,
  outcome_variable_levels = NULL,
  outcome_variable_name = "My outcome variable",
  conf_level = 0.95,
  count_NA = FALSE
)

Arguments

data

For raw data - a data frame or tibble

outcome_variable

For raw data - The column name of the outcome variable, which must be a factor, or a vector that is a factor

cases

For summary data - A vector of cases

case_label

A numeric or string indicating which level of the factor to estimate. Defaults to 1, meaning first level is analyzed

outcome_variable_levels

For summary data - optional vector of 2 characters indicating name of the count level and name of the not count level. Defaults to "Affected" and "Not Affected"

outcome_variable_name

Optional friendly name for the outcome variable. Defaults to 'My outcome variable' or the outcome variable column name if a data frame is passed.

conf_level

The confidence level for the confidence interval. Given in decimal form. Defaults to 0.95.

count_NA

Logical to count NAs (TRUE) in total N or not (FALSE)

Details

Once you generate an estimate with this function, you can visualize it with plot_proportion().

If you want to compare your estimate to a known value or reference, then use estimate_pdiff_one().

The estimated proportions are from statpsych::ci.prop1() (renamed ci.prop as of statpsych 1.6).

Value

Returns an object of class esci_estimate

Examples

# From raw data
data("data_campus_involvement")

estimate_from_raw <- esci::estimate_proportion(
  esci::data_campus_involvement,
  CommuterStatus
)


# To visualize the estimate
myplot_from_raw <- esci::plot_proportion(estimate_from_raw)


# From summary data
estimate_from_summary <- esci::estimate_proportion(
  cases = c(8, 22-8),
  outcome_variable_levels = c("Affected", "Not Affected")
)

# To visualize the estimate
myplot_from_summary<- esci::plot_proportion(estimate_from_summary)


[Package esci version 1.0.3 Index]