Learn R Programming

riskyr (version 0.1.0)

comp_prob_freq: Compute probabilities from (4 essential) frequencies.

Description

comp_prob_freq computes current probability information from 4 essential frequencies (hi, mi, fa, cr). It returns a list of 10 probabilities prob as its output.

Usage

comp_prob_freq(hi = freq$hi, mi = freq$mi, fa = freq$fa, cr = freq$cr)

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).

Details

Key relationships:

  • Other functions translating between representational formats:

    1. comp_prob_freq (defined here) is an analog to 3 other format conversion functions:

    2. comp_freq_freq computes current frequency information contained in freq from 4 essential frequencies (hi, mi, fa, cr).

    3. comp_freq_prob computes current frequency information contained in freq from 3 essential probabilities (prev, sens, spec).

    4. comp_prob_prob computes current probability information contained in prob from 3 essential probabilities (prev, sens, spec).

  • Two perspectives:

    A population of N individuals can be split into 2 subsets in 2 different ways:

    1. by condition:

      The frequency cond.true depends on the prevalence prev and the frequency cond.false depends on the prevalence's complement 1 - prev.

    2. by decision:

      The frequency dec.pos depends on the proportion of positive decisions ppod and the frequency dec.neg depends on the proportion of negative decisions 1 - ppod.

    The population size N is a free parameter (independent of the essential probabilities prev, sens, and spec).

    If N is unknown (NA), a suitable minimum value can be computed by comp_min_N.

  • Combinations of frequencies:

    In a population of size N the following relationships hold:

    1. N = cond.true + cond.false = (hi + mi) + (fa + cr) (by condition)

    2. N = dec.pos + dec.neg = (hi + fa) + (mi + cr) (by decision)

    3. N = hi + mi + fa + cr (by condition x decision)

    The two perspectives (by condition vs. by decision) combine the 4 essential frequencies (i.e., hi, mi, fa, cr) in 2 different ways.

  • Defining probabilities in terms of frequencies:

    Probabilities are -- determine, describe, or are defined as -- the relationships between frequencies. Thus, they can be computed as ratios between frequencies.

    The following relationships hold (and are used in computations):

    1. prevalence prev:

      prev = cond.true/N = (hi + mi) / (hi + mi + fa + cr)

    2. sensitivity sens:

      sens = hi/cond.true = hi / (hi + mi) = (1 - mirt)

    3. miss rate mirt:

      mirt = mi/cond.true = mi / (hi + mi) = (1 - sens)

    4. specificity spec:

      spec = cr/cond.false = cr / (fa + cr) = (1 - fart)

    5. false alarm rate fart:

      fart = fa/cond.false = fa / (fa + cr) = (1 - spec)

    6. proportion of positive decisions ppod:

      ppod = dec.pos/N = (hi + fa) / (hi + mi + fa + cr)

    7. positive predictive value PPV:

      PPV = hi/dec.pos = hi / (hi + fa) = (1 - FDR)

    8. negative predictive value NPV:

      NPV = cr/dec.neg = cr / (mi + cr) = (1 - FOR)

    9. false detection rate FDR:

      FDR = fa/dec.pos = fa / (hi + fa) = (1 - PPV)

    10. false omission rate FOR:

      FOR = mi/dec.neg = mi / (mi + cr) = (1 - NPV)

See Also

comp_freq_freq computes current frequency information from (4 essential) frequencies; comp_freq_prob computes current frequency information from (3 essential) probabilities; comp_prob_prob computes current probability information from (3 essential) probabilities; num contains basic numeric parameters; init_num initializes basic numeric parameters; prob contains current probability information; comp_prob computes current probability information; freq contains current frequency information; comp_freq computes current frequency information; is_prob verifies probability inputs; is_freq verifies frequency inputs.

Other functions computing probabilities: comp_FDR, comp_FOR, comp_NPV, comp_PPV, comp_accu, comp_acc, comp_comp_pair, comp_complement, comp_complete_prob_set, comp_fart, comp_mirt, comp_ppod, comp_prob, comp_sens, comp_spec

Other format conversion functions: comp_freq_freq, comp_freq_prob, comp_prob_prob

Examples

Run this code
# NOT RUN {
## Basics:
comp_prob_freq()
all.equal(prob, comp_prob_freq())  # => should be TRUE!


## Circular chain:
# 1. Current numeric parameters:
num

# 2. Compute all 10 probabilities in prob (from essential probabilities):
prob <- comp_prob()

# 3. Compute 9 frequencies in freq from probabilities:
freq <- comp_freq(round = FALSE)   # prevent rounding (to obtain same probabilities later)
freq

# 4. Compute all 10 probabilities again (but now from frequencies):
prob_freq <- comp_prob_freq()
prob_freq

# 5. Check equality of results (steps 2. and 4.):
all.equal(prob, prob_freq)  # => should be TRUE


# }

Run the code above in your browser using DataLab