comp_prob_freq computes current probability information
from 4 essential frequencies
(hi, mi, fa, cr).
It returns a list of 11 frequencies freq
for a population of N individuals
as its output.
Details
Key relationships between frequencies and probabilities
(see documentation of comp_freq or comp_prob for details):
Three perspectives on a population:
by condition / by decision / by accuracy.
Defining probabilities in terms of frequencies:
Probabilities can be computed as ratios between frequencies, but beware of rounding issues.
Functions translating between representational formats:
comp_prob_prob, comp_prob_freq,
comp_freq_prob, comp_freq_freq
(see documentation of comp_prob_prob for details).
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_acc(),
comp_accu_freq(),
comp_accu_prob(),
comp_comp_pair(),
comp_complement(),
comp_complete_prob_set(),
comp_err(),
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
## Basics:
comp_prob_freq() # => computes prob from current freq
#> $prev
#> [1] 0.25
#>
#> $sens
#> [1] 0.848
#>
#> $mirt
#> [1] 0.152
#>
#> $spec
#> [1] 0.7493333
#>
#> $fart
#> [1] 0.2506667
#>
#> $ppod
#> [1] 0.4
#>
#> $PPV
#> [1] 0.53
#>
#> $FDR
#> [1] 0.47
#>
#> $NPV
#> [1] 0.9366667
#>
#> $FOR
#> [1] 0.06333333
#>
#> $acc
#> [1] 0.774
#>
#> $p_acc_hi
#> [1] 0.2739018
#>
#> $p_err_fa
#> [1] 0.8318584
#>
## Beware of rounding:
all.equal(prob, comp_prob_freq()) # => would be TRUE (IF freq were NOT rounded)!
#> [1] "Component “sens”: Mean relative difference: 0.002352941"
#> [2] "Component “mirt”: Mean relative difference: 0.01333333"
#> [3] "Component “spec”: Mean relative difference: 0.0008888889"
#> [4] "Component “fart”: Mean relative difference: 0.002666667"
#> [5] "Component “PPV”: Mean relative difference: 0.002352941"
#> [6] "Component “FDR”: Mean relative difference: 0.002666667"
#> [7] "Component “NPV”: Mean relative difference: 0.0008888889"
#> [8] "Component “FOR”: Mean relative difference: 0.01333333"
#> [9] "Component “acc”: Mean relative difference: 0.001290323"
#> [10] "Component “p_acc_hi”: Mean relative difference: 0.001063991"
#> [11] "Component “p_err_fa”: Mean relative difference: 0.001769912"
fe <- comp_freq(round = FALSE) # compute exact freq (not rounded)
all.equal(prob, comp_prob_freq(fe$hi, fe$mi, fe$fa, fe$cr)) # is TRUE (qed).
#> [1] TRUE
## Explain by circular chain (compute prob 1. from num and 2. from freq)
# 0. Inspect current numeric parameters:
num
#> $prev
#> [1] 0.25
#>
#> $sens
#> [1] 0.85
#>
#> $spec
#> [1] 0.75
#>
#> $fart
#> [1] 0.25
#>
#> $N
#> [1] 1000
#>
# 1. Compute currently 11 probabilities in prob (from essential probabilities):
prob <- comp_prob()
prob
#> $prev
#> [1] 0.25
#>
#> $sens
#> [1] 0.85
#>
#> $mirt
#> [1] 0.15
#>
#> $spec
#> [1] 0.75
#>
#> $fart
#> [1] 0.25
#>
#> $ppod
#> [1] 0.4
#>
#> $PPV
#> [1] 0.53125
#>
#> $FDR
#> [1] 0.46875
#>
#> $NPV
#> [1] 0.9375
#>
#> $FOR
#> [1] 0.0625
#>
#> $acc
#> [1] 0.775
#>
#> $p_acc_hi
#> [1] 0.2741935
#>
#> $p_err_fa
#> [1] 0.8333333
#>
# 2. Compute currently 11 frequencies in freq (from essential probabilities):
freq <- comp_freq(round = FALSE) # no rounding (to obtain same probabilities later)
freq
#> $N
#> [1] 1000
#>
#> $cond_true
#> [1] 250
#>
#> $cond_false
#> [1] 750
#>
#> $dec_pos
#> [1] 400
#>
#> $dec_neg
#> [1] 600
#>
#> $dec_cor
#> [1] 775
#>
#> $dec_err
#> [1] 225
#>
#> $hi
#> [1] 212.5
#>
#> $mi
#> [1] 37.5
#>
#> $fa
#> [1] 187.5
#>
#> $cr
#> [1] 562.5
#>
# 3. Compute currently 11 probabilities again (but now from frequencies):
prob_freq <- comp_prob_freq()
prob_freq
#> $prev
#> [1] 0.25
#>
#> $sens
#> [1] 0.848
#>
#> $mirt
#> [1] 0.152
#>
#> $spec
#> [1] 0.7493333
#>
#> $fart
#> [1] 0.2506667
#>
#> $ppod
#> [1] 0.4
#>
#> $PPV
#> [1] 0.53
#>
#> $FDR
#> [1] 0.47
#>
#> $NPV
#> [1] 0.9366667
#>
#> $FOR
#> [1] 0.06333333
#>
#> $acc
#> [1] 0.774
#>
#> $p_acc_hi
#> [1] 0.2739018
#>
#> $p_err_fa
#> [1] 0.8318584
#>
# 4. Check equality of probabilities (in steps 1. and 3.):
all.equal(prob, prob_freq) # => should be TRUE!
#> [1] "Component “sens”: Mean relative difference: 0.002352941"
#> [2] "Component “mirt”: Mean relative difference: 0.01333333"
#> [3] "Component “spec”: Mean relative difference: 0.0008888889"
#> [4] "Component “fart”: Mean relative difference: 0.002666667"
#> [5] "Component “PPV”: Mean relative difference: 0.002352941"
#> [6] "Component “FDR”: Mean relative difference: 0.002666667"
#> [7] "Component “NPV”: Mean relative difference: 0.0008888889"
#> [8] "Component “FOR”: Mean relative difference: 0.01333333"
#> [9] "Component “acc”: Mean relative difference: 0.001290323"
#> [10] "Component “p_acc_hi”: Mean relative difference: 0.001063991"
#> [11] "Component “p_err_fa”: Mean relative difference: 0.001769912"
