comp_popu: Compute a population table (data) from frequencies...

View source: R/comp_popu.R

comp_popuR Documentation

Compute a population table (data) from frequencies (description).

Description

comp_popu computes a table popu (as an R data frame) from the current frequency information (contained in freq).

Usage

comp_popu(
  hi = freq$hi,
  mi = freq$mi,
  fa = freq$fa,
  cr = freq$cr,
  cond_lbl = txt$cond_lbl,
  cond_true_lbl = txt$cond_true_lbl,
  cond_false_lbl = txt$cond_false_lbl,
  dec_lbl = txt$dec_lbl,
  dec_pos_lbl = txt$dec_pos_lbl,
  dec_neg_lbl = txt$dec_neg_lbl,
  sdt_lbl = txt$sdt_lbl,
  hi_lbl = txt$hi_lbl,
  mi_lbl = txt$mi_lbl,
  fa_lbl = txt$fa_lbl,
  cr_lbl = txt$cr_lbl
)

Arguments

hi

The number of hits hi (or true positives).

mi

The number of misses mi (or false negatives).

fa

The number of false alarms fa (or false positives).

cr

The number of correct rejections cr (or true negatives).

cond_lbl

Text label for condition dimension ("by cd" perspective).

cond_true_lbl

Text label for cond_true cases.

cond_false_lbl

Text label for cond_false cases.

dec_lbl

Text label for decision dimension ("by dc" perspective).

dec_pos_lbl

Text label for dec_pos cases.

dec_neg_lbl

Text label for dec_neg cases.

sdt_lbl

Text label for 4 cases/combinations (SDT classifications).

hi_lbl

Text label for hi cases.

mi_lbl

Text label for mi cases.

fa_lbl

Text label for fa cases.

cr_lbl

Text label for cr cases.

Format

An object of class data.frame with N rows and 3 columns (e.g., "X/truth/cd", "Y/test/dc", "SDT/cell/class").

Details

By default, comp_popu uses the text settings contained in txt.

A visualization of the current population popu is provided by plot_icons.

Value

A data frame popu containing N rows (individual cases) and 3 columns (e.g., "X/truth/cd", "Y/test/dc", "SDT/cell/class"). encoded as ordered factors (with 2, 2, and 4 levels, respectively).

See Also

read_popu creates a scenario (description) from data (as df); write_popu creates data (as df) from a riskyr scenario (description); popu for data format; num for basic numeric parameters; freq for current frequency information; txt for current text settings; pal for current color settings.

Other functions converting data/descriptions: read_popu(), write_popu()

Examples

popu <- comp_popu()  # => initializes popu (with current values of freq and txt)
dim(popu)            # => N x 3
head(popu)

# (A) Diagnostic/screening scenario (using default labels):
comp_popu(hi = 4, mi = 1, fa = 2, cr = 3)  # => computes a table of N = 10 cases.

# (B) Intervention/treatment scenario:
comp_popu(hi = 3, mi = 2, fa = 1, cr = 4,
          cond_lbl = "Treatment", cond_true_lbl = "pill", cond_false_lbl = "placebo",
          dec_lbl = "Health status", dec_pos_lbl = "healthy", dec_neg_lbl = "sick")

# (C) Prevention scenario (e.g., vaccination):
comp_popu(hi = 3, mi = 2, fa = 1, cr = 4,
          cond_lbl = "Vaccination", cond_true_lbl = "yes", cond_false_lbl = "no",
          dec_lbl = "Disease", dec_pos_lbl = "no flu", dec_neg_lbl = "flu")


hneth/riskyr documentation built on Feb. 18, 2024, 6:01 p.m.