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

Arguments

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 method argument to p.adjust().

Value

A numeric vector with the same length as obs representing corresponding p-values after possible adjustment for multiple comparisons.

Details

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

See also

Examples

# 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] 1
summ_pval(d_dis, 3, method = "right")
#> [1] 0.6666667
summ_pval(d_dis, 3, method = "left")
#> [1] 0.6666667
# Type "continuous" d_norm <- as_d(dnorm) summ_pval(d_norm, 2, method = "both")
#> [1] 0.04549837
summ_pval(d_norm, 2, method = "right")
#> [1] 0.02274919
summ_pval(d_norm, 2, method = "left")
#> [1] 0.9772508
# Adjustment is made for multiple observed values summ_pval(d_norm, seq(0, 2, by = 0.1))
#> [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