Quantifies the information about direction in a posterior distribution based on the directional probability.
This function calculates such information using the difference in the probability of direction (see probability_direction()), after converting each probability to bits (also see svalue().
Usage
directional_information(
x,
side = "median",
threshold = 0,
threshold_split = "proportional",
na_rm = FALSE
)Arguments
- x
A numeric vector of MCMC values.
- side
A string indicating whether to calculate the directional information relative to the left side (
"left";x < threshold), or the right side ("right";x > threshold). Positive information suggests greater evidence for the specified side. Defaults to"median", which uses the side of the median ofxviadirection().- threshold
A number of the threshold value.
- threshold_split
A string indicating how to deal with threshold values:
"left"to include them on the left side,"right"to include them on the right side,"equal"to split them equally between the left and side,"proportional"(default) to split them between the left and right sides proportionally to the values ofxon the left and right sides,"exclude"to drop the values ofxequal tothreshold(identical to using"proportional").
- na_rm
A flag specifying whether to remove missing values.
Value
A number indicating the directional information in bits.
If x has NA values but na_rm is FALSE, returns NA_real.
References
Kery, M., and Schaub, M. 2011. Bayesian population analysis using WinBUGS: a hierarchical perspective. Academic Press, Boston. Available from https://www.vogelwarte.ch/en/research/population-biology/book-bpa/.
See also
Other summary:
direction(),
kurtosis(),
lower(),
probability_direction(),
pvalue(),
pzeros(),
skewness(),
svalue(),
upper(),
variance(),
xtr_mean(),
xtr_median(),
xtr_sd(),
zeros(),
zscore()
Examples
directional_information(0)
#> [1] 0
directional_information(1) # one coin flip of information
#> [1] 1
directional_information(c(1, 1)) # two coin flips
#> [1] 2
directional_information(c(1, 1, -1)) # x[2] and x[3] cancel out
#> [1] 1
directional_information(c(1, 1, -1, -1)) # both sides cancel out
#> [1] 0
directional_information(rnorm(1e3, mean = 0))
#> [1] 0.0577155
directional_information(rnorm(1e3, mean = 1))
#> [1] 2.328864
directional_information(rnorm(1e3, mean = 10)) # all coin flips are positive
#> [1] 1000
directional_information(rnorm(1e3, mean = -10)) # all coin flips are negative
#> [1] 1000
directional_information(rnorm(1e3, mean = 1e3)) # only quantiles matter
#> [1] 1000
directional_information(rnorm(1e6, mean = 1e3)) # more `x` implies more info
#> [1] 1e+06
