R/comp_prob_prob.R
comp_NPV.Rd
comp_NPV
computes the negative predictive value NPV
from 3 essential probabilities
prev
, sens
, and spec
.
comp_NPV(prev, sens, spec)
The condition's prevalence prev
(i.e., the probability of condition being TRUE
).
The decision's sensitivity sens
(i.e., the conditional probability of a positive decision
provided that the condition is TRUE
).
The decision's specificity value spec
(i.e., the conditional probability
of a negative decision provided that the condition is FALSE
).
The negative predictive value NPV
as a probability.
A warning is provided for NaN values.
comp_NPV
uses probabilities (not frequencies)
and does not round results.
comp_spec
and comp_PPV
compute related probabilities;
is_extreme_prob_set
verifies extreme cases;
comp_complement
computes a probability's complement;
is_complement
verifies probability complements;
comp_prob
computes current probability information;
prob
contains current probability information;
is_prob
verifies probabilities.
Other functions computing probabilities:
comp_FDR()
,
comp_FOR()
,
comp_PPV()
,
comp_accu_freq()
,
comp_accu_prob()
,
comp_acc()
,
comp_comp_pair()
,
comp_complement()
,
comp_complete_prob_set()
,
comp_err()
,
comp_fart()
,
comp_mirt()
,
comp_ppod()
,
comp_prob_freq()
,
comp_prob()
,
comp_sens()
,
comp_spec()
# (1) Ways to work:
comp_NPV(.50, .500, .500) # => NPV = 0.5
#> [1] 0.5
comp_NPV(.50, .333, .666) # => NPV = 0.4996
#> [1] 0.4996249
# (2) Watch out for vectors:
prev <- seq(0, 1, .1)
comp_NPV(prev, .5, .5) # => without NaN values
#> [1] 1.0 0.9 0.8 0.7 0.6 0.5 0.4 0.3 0.2 0.1 0.0
comp_NPV(prev, 1, 0) # => with NaN values
#> Warning: NPV is NaN.
#> [1] NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
# (3) Watch out for extreme values:
comp_NPV(1, 1, 1) # => NaN, as cr = 0 and mi = 0: 0/0
#> Warning: NPV is NaN.
#> [1] NaN
comp_NPV(1, 1, 0) # => NaN, as cr = 0 and mi = 0: 0/0
#> Warning: NPV is NaN.
#> [1] NaN
comp_NPV(.5, sens = 1, spec = 0) # => NaN, no dec_neg cases: NPV = 0/0 = NaN
#> Warning: NPV is NaN.
#> [1] NaN
is_extreme_prob_set(.5, sens = 1, spec = 0) # => verifies extreme cases
#> Warning: Extreme case (sens = 1 & spec = 0):
#> 0 mi (FN) and 0 cr (TN) cases; 0 dec_neg cases; NPV = NaN.
#> [1] TRUE