| negbinom.em {mederrRank} | R Documentation | 
Expectation-Maximization Algorithm for the Negative Binomial Distribution
Description
This function provides the empirical Bayes estimates for the parameters theta of a negative binomial distribution (see dnegbinom) using an Expectation-Maximization algorithm.
Usage
negbinom.em(dat, theta0, maxiter = 50000, toler = 0.01,
	se = TRUE, stratified = FALSE)
Arguments
| dat | an object of class "mederrData". | 
| theta0 | initial values for the parameters to be optimized over. | 
| maxiter | a positive integer specifying the maximum number of iterations to be performed before the program is terminated. | 
| toler | a positive scalar giving the tolerance at which the scaled gradient is considered close enough to zero to terminate the algorithm. | 
| se | logical; if TRUE the standard errors of the estimates are also returned. | 
| stratified | logical; if TRUE the analysis will be performed by stratifying on the hospitals. | 
Details
For further details see Myers et al. (2011).
Value
negbinom.em returns a list with components:
| theta.hat | The best set of parameters found. | 
| final.err | The last change in the log-likelihood; it has to be smaller than the  | 
| final.ll | The likelihood value corresponding to  | 
| final.score | The log-likelihood score value corresponding to  | 
| num.iter | The number of iterations performed to find the proposed solution. | 
| se | Only if argument  | 
| N | The vector of observed error profiles counts. | 
| E | The vector of expected error profiles counts. | 
| prior | A character string giving the prior used; for this function is set to "gamma", i.e. a gamma distribution. | 
Author(s)
Sergio Venturini sergio.venturini@unicatt.it,
Jessica A. Myers jmyers6@partners.org
References
DuMouchel W. (1999), "Bayesian Data Mining in Large Frequency Tables, with an Application to the FDA Spontaneous Reporting System". The American Statistician, 53, 177-190.
Myers, J. A., Venturini, S., Dominici, F. and Morlock, L. (2011), "Random Effects Models for Identifying the Most Harmful Medication Errors in a Large, Voluntary Reporting Database". Technical Report.
See Also
dnegbinom,
EBGM,
mixnegbinom.em.
Examples
data("simdata", package = "mederrRank")
summary(simdata)
## Not run: 
fit <- bhm.mcmc(simdata, nsim = 1000, burnin = 500, scale.factor = 1.1)
resamp <- bhm.resample(fit, simdata, p.resample = .1,
	k = c(3, 6, 10, 30, 60, Inf), eta = c(.5, .8, 1, 1.25, 2))
fit2 <- bhm.constr.resamp(fit, resamp, k = 3, eta = .8)
plot(fit, fit2, simdata)
## End(Not run)
theta0 <- runif(2, 0, 5)
ans <- negbinom.em(simdata, theta0, 50000, 0.01,
	se = TRUE, stratified = TRUE)
ans$theta
ans$se
## Not run: 
summary(fit2, ans, simdata)
## End(Not run)