mgpsEM: Multi-Item Gamma-Poisson Shrinker (MGPS)

Description Usage Arguments Value References See Also Examples

View source: R/mgpsEM.R

Description

This mgpsEM function finds hyperparameter estimates by implementing the Expectation-Maximization (EM) algorithm.nlminb function is used to maximize the loglikelihood function.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
mgpsEM(
  alpha1,
  beta1,
  alpha2,
  beta2,
  pi,
  N,
  E,
  weight,
  iteration,
  Loglik = FALSE,
  zeroes = FALSE,
  N_star = 1
)

Arguments

alpha1

initial shape parameter guess of the first gamma distribution

beta1

initial rate parameter guess of the first gamma distribution

alpha2

initial shape parameter guess of the second gamma distribution

beta2

initial rate parameter guess of the second gamma distribution

pi

initial mixing proportion guess of the two gamma distributions

N

vector of Nij values

E

vector of Eij values

weight

set weight = rep(1, length(N)) if N and E are not squashed data, or input the weight vector corresponding to the squashed Nij vector.

iteration

number of EM algorithm iterations to run

Loglik

whether to return the loglikelihood of each iteration or not (TRUE or FALSE)

zeroes

A logical scalar specifying if zero counts should be included.

N_star

the minimum Nij count size to be used for hyperparameter estimation. If zeroes are included in Nij vector, please set N_star = NULL

Value

a list including the following:

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

openEBGM, nlminb

Examples

1
2
3
4
5
Nij = rnbinom(100, size = 2, prob = 0.3)
Eij = runif(100, 0, 2)
par_estimated = mgpsEM(2, 4, 0.2, 0.1, 0.33, Nij, Eij, rep(1, length(Nij)), iteration = 10, Loglik = TRUE, zeros = TRUE, N_star = 1)
par_estimated$theta_EM
par_estimated$Loglik

sidiwang/hgzips documentation built on Jan. 19, 2021, 4:09 p.m.