riskyr (version 0.2.0)

comp_popu: Compute a population table from frequencies.

Description

comp_popu is a function that 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.

Value

A data frame popu containing N rows (individual cases) and 3 columns ("Truth", "Decision", "SDT") encoded as ordered factors (with 2, 2, and 4 levels, respectively).

Format

An object of class data.frame with N rows and 3 columns ("Truth", "Decision", "SDT").

Details

comp_popu also uses the current text settings contained in txt.

A visualization of the current population contained in popu is provided by plot_icon.

See Also

the corresponding data frame popu; read_popu interprets a data frame as a riskyr scenario; num for basic numeric parameters; freq for current frequency information; txt for current text settings; pal for current color settings.

Other functions computing frequencies: comp_freq_freq, comp_freq_prob, comp_freq, comp_min_N, comp_prob_prob

Examples

Run this code
# NOT RUN {
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")

# }

Run the code above in your browser using DataCamp Workspace