proportion_tests: Proportions and Tests of Proportions

propiR Documentation

Proportions and Tests of Proportions

Description

Immediate and data-based commands for confidence intervals, exact binomial tests, and one- or two-sample z tests of proportions. prtest() and prtesti() support a one-sample null proportion through p0; prtest() also supports hierarchical grouping.

Usage

propi(
  events,
  total,
  p0 = NULL,
  method = c("all", "exact", "wilson", "wald"),
  alternative = c("two.sided", "less", "greater"),
  level = 0.95,
  digits = 3,
  p_digits = 3,
  show = TRUE,
  console = FALSE
)

bitesti(
  total,
  events,
  p = 0.5,
  alternative = c("two.sided", "less", "greater"),
  level = 0.95,
  digits = 3,
  p_digits = 3,
  show = TRUE,
  console = FALSE
)

prtesti(
  events1,
  n1,
  events2 = NULL,
  n2 = NULL,
  p0 = NULL,
  alternative = c("two.sided", "less", "greater"),
  level = 0.95,
  digits = 3,
  p_digits = 3,
  show = TRUE,
  console = FALSE
)

propi(
  events, total, p0 = NULL, method = c("all", "exact", "wilson", "wald"),
  alternative = c("two.sided", "less", "greater"), level = 0.95, digits = 3,
  p_digits = 3, show = TRUE, console = FALSE
)

bitesti(
  total, events, p = 0.5, alternative = c("two.sided", "less", "greater"),
  level = 0.95, digits = 3, p_digits = 3, show = TRUE, console = FALSE
)

prtesti(
  events1, n1, events2 = NULL, n2 = NULL, p0 = NULL,
  alternative = c("two.sided", "less", "greater"), level = 0.95, digits = 3,
  p_digits = 3, show = TRUE, console = FALSE
)

prop(
  x, data = NULL, event = NULL, p0 = NULL,
  method = c("all", "exact", "wilson", "wald"),
  alternative = c("two.sided", "less", "greater"), level = 0.95, digits = 3,
  p_digits = 3, show = TRUE, console = FALSE
)

bitest(
  x, p = 0.5, data = NULL, event = NULL,
  alternative = c("two.sided", "less", "greater"), level = 0.95, digits = 3,
  p_digits = 3, show = TRUE, console = FALSE
)

prtest(
  x, by = NULL, data = NULL, event = NULL, p0 = NULL,
  alternative = c("two.sided", "less", "greater"), level = 0.95, digits = 3,
  p_digits = 3, show = TRUE, console = FALSE
)

prop(
  x,
  data = NULL,
  event = NULL,
  p0 = NULL,
  method = c("all", "exact", "wilson", "wald"),
  alternative = c("two.sided", "less", "greater"),
  level = 0.95,
  digits = 3,
  p_digits = 3,
  show = TRUE,
  console = FALSE
)

bitest(
  x,
  p = 0.5,
  data = NULL,
  event = NULL,
  alternative = c("two.sided", "less", "greater"),
  level = 0.95,
  digits = 3,
  p_digits = 3,
  show = TRUE,
  console = FALSE
)

prtest(
  x,
  by = NULL,
  data = NULL,
  event = NULL,
  p0 = NULL,
  alternative = c("two.sided", "less", "greater"),
  level = 0.95,
  digits = 3,
  p_digits = 3,
  show = TRUE,
  console = FALSE
)

Arguments

events, total

Number of events and total observations.

p0

Null proportion.

method

Confidence interval method: "all", "exact", "wilson", or "wald".

alternative

Alternative hypothesis.

level

Confidence level.

digits, p_digits

Decimal places for estimates and p-values.

show

Logical; open the formatted result in the Viewer. Default TRUE.

console

Logical; also print the traditional text result in the Console. Default FALSE.

p

Null probability for bitesti() and bitest().

events1, n1

Events and total in sample 1.

events2, n2

Optional events and total in sample 2.

x

Binary variable.

data

Data frame. If NULL, active data is used.

event

Event level. The last observed level is used by default.

by

Optional two-level grouping variable. For prtest(), by = vars(region, sex, group) performs the two-proportion comparison inside region and sex strata.

Value

Invisibly returns an object of class r4vn_stat.

Examples

propi(32, 100, p0 = .25)
bitesti(40, 23, p = 0.5)
prtesti(30, 100, p0 = .20)
prtesti(30, 100, 20, 80)

d <- data.frame(case = c(rep(1,30), rep(0,70), rep(1,20), rep(0,60)),
                group = rep(c("A","B"), c(100,80)))
prtest(case, data = d, p0 = .25, event = 1)
prtest(case, by = group, data = d, event = 1)


R4VN documentation built on Sept. 30, 2026, 5:13 p.m.