View source: R/f_posteriorCalcs.R
ebgm | R Documentation |
ebgm
calculates the Empirical Bayes Geometric Mean (EBGM),
which is ‘the geometric mean of the empirical Bayes posterior
distribution of the “true” RR’ (DuMouchel 1999, see Eq.11). The
EBGM is essentially a version of the relative reporting ratio
(RR) that uses Bayesian shrinkage.
ebgm(theta_hat, N, E, qn, digits = 2)
theta_hat |
A numeric vector of hyperparameter estimates (likely from
|
N |
A whole number vector of actual counts from
|
E |
A numeric vector of expected counts from |
qn |
A numeric vector of posterior probabilities that |
digits |
A scalar whole number that determines the number of decimal places used when rounding the results. |
The hyperparameter estimates (theta_hat
) are:
\alpha_1, \beta_1
: Parameter estimates of the first
component of the prior distribution
\alpha_2, \beta_2
: Parameter estimates of the second
component
P
: Mixture fraction estimate of the prior distribution
A numeric vector of EBGM scores.
DuMouchel W (1999). "Bayesian Data Mining in Large Frequency Tables, With an Application to the FDA Spontaneous Reporting System." The American Statistician, 53(3), 177-190.
autoHyper
, exploreHypers
,
negLLsquash
, negLL
,
negLLzero
, and negLLzeroSquash
for
hyperparameter estimation.
processRaw
for finding counts.
Qn
for finding mixture fractions.
Other posterior distribution functions:
Qn()
,
quantBisect()
data.table::setDTthreads(2) #only needed for CRAN checks
theta_init <- data.frame(
alpha1 = c(0.5, 1),
beta1 = c(0.5, 1),
alpha2 = c(2, 3),
beta2 = c(2, 3),
p = c(0.1, 0.2)
)
data(caers)
proc <- processRaw(caers)
squashed <- squashData(proc, bin_size = 300, keep_pts = 10)
squashed <- squashData(squashed, count = 2, bin_size = 13, keep_pts = 10)
theta_hat <- autoHyper(data = squashed, theta_init = theta_init)$estimates
qn <- Qn(theta_hat, N = proc$N, E = proc$E)
proc$EBGM <- ebgm(theta_hat, N = proc$N, E = proc$E, qn = qn)
head(proc)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.