summ_pval()
computes p-value(s) based on supplied distribution and observed
value(s). There are several methods of computing p-values ("both", "right",
and "left") as well as several types of multiple comparison adjustments
(using on stats::p.adjust()
).
summ_pval(f, obs, method = "both", adjust = "holm")
f | A pdqr-function representing distribution. |
---|---|
obs | Numeric vector of observed values to be used as threshold for p-value. Can have multiple values, in which case output will be adjusted for multiple comparisons with p.adjust(). |
method | Method representing direction of p-value computation. Should be one of "both", "right", "left". |
adjust | Adjustment method as |
A numeric vector with the same length as obs
representing
corresponding p-values after possible adjustment for multiple comparisons.
Method "both" for each element in obs
computes two-sided p-value
as min(1, 2 * min(right_p_val, left_p_val))
, where right_p_val
and
left_p_val
are right and left one-sided p-values (ones which are computed
with "right" and "left" methods) of obs
's elements correspondingly.
Method "right" for each element x
of obs
computes probability of f >= x
being true (more strictly, of random variable, represented by f
, being not
less than x
). This corresponds to right one-sided p-value.
Method "left" for each element x
of obs
computes probability of f <= x
,
which is a left one-sided p-value.
Note that by default multiple p-values in output are adjusted with
p.adjust(*, method = adjust)
. To not do any adjustment, use adjust = "none"
.
Other summary functions:
summ_center()
,
summ_classmetric()
,
summ_distance()
,
summ_entropy()
,
summ_hdr()
,
summ_interval()
,
summ_moment()
,
summ_order()
,
summ_prob_true()
,
summ_quantile()
,
summ_roc()
,
summ_separation()
,
summ_spread()
# Type "discrete"
d_dis <- new_d(data.frame(x = 1:5, prob = c(1, 2, 3, 2, 1) / 9), "discrete")
summ_pval(d_dis, 3, method = "both")
#> [1] 1summ_pval(d_dis, 3, method = "right")
#> [1] 0.6666667summ_pval(d_dis, 3, method = "left")
#> [1] 0.6666667#> [1] 0.04549837summ_pval(d_norm, 2, method = "right")
#> [1] 0.02274919summ_pval(d_norm, 2, method = "left")
#> [1] 0.9772508#> [1] 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000
#> [8] 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000
#> [15] 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 0.9554658## Use `adjust = "none"` for to not do any adjustment
summ_pval(d_norm, seq(0, 2, by = 0.1), adjust = "none")
#> [1] 1.00000000 0.92034417 0.84148028 0.76417670 0.68915592 0.61707434
#> [7] 0.54850536 0.48392631 0.42370968 0.36811902 0.31730918 0.27133070
#> [13] 0.23013784 0.19359939 0.16151167 0.13361270 0.10959683 0.08912913
#> [19] 0.07185880 0.05743125 0.04549837