Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

Qn

Calculate Qn


Description

Qn calculates Q_n, the posterior probability that λ came from the first component of the mixture, given N = n (Eq. 6, DuMouchel 1999). Q_n is the mixture fraction for the posterior distribution.

Usage

Qn(theta_hat, N, E)

Arguments

theta_hat

A numeric vector of hyperparameter estimates (likely from autoHyper or from directly minimizing negLLsquash) ordered as: α_1, β_1, α_2, β_2, P.

N

A whole number vector of actual counts from processRaw.

E

A numeric vector of expected counts from processRaw.

Details

The hyperparameter estimates (theta_hat) are:

  • α_1, β_1: Parameter estimates of the first component of the prior distribution

  • α_2, β_2: Parameter estimates of the second component

  • P: Mixture fraction estimate of the prior distribution

Value

A numeric vector of probabilities.

References

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.

See Also

autoHyper, exploreHypers, negLLsquash, negLL, negLLzero, and negLLzeroSquash for hyperparameter estimation.

processRaw for finding counts.

Other posterior distribution functions: ebgm(), quantBisect()

Examples

theta_init <- data.frame(
  alpha1 = c(0.2, 0.1),
  beta1  = c(0.1, 0.1),
  alpha2 = c(2,   10),
  beta2  = c(4,   10),
  p      = c(1/3, 0.2)
)
data(caers)
proc <- processRaw(caers)
squashed <- squashData(proc, bin_size = 100, keep_pts = 100)
squashed <- squashData(squashed, count = 2, bin_size = 10, keep_pts = 20)
suppressWarnings(
  theta_hat <- autoHyper(data = squashed, theta_init = theta_init)$estimates
)
qn <- Qn(theta_hat, N = proc$N, E = proc$E)
head(qn)

openEBGM

EBGM Disproportionality Scores for Adverse Event Data Mining

v0.8.3
GPL-2 | GPL-3
Authors
John Ihrie [cre, aut], Travis Canida [aut], Ismaïl Ahmed [ctb] (author of 'PhViD' package (derived code)), Antoine Poncet [ctb] (author of 'PhViD'), Sergio Venturini [ctb] (author of 'mederrRank' package (derived code)), Jessica Myers [ctb] (author of 'mederrRank')
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.