ebpm_gamma_mixture: Empirical Bayes Poisson Mean with Mixture of Gamma as Prior...

View source: R/ebpm_gamma_mixture.R

ebpm_gamma_mixtureR Documentation

Empirical Bayes Poisson Mean with Mixture of Gamma as Prior (still in development)

Description

Uses Empirical Bayes to fit the model

x_j | \lambda_j ~ Poi(s_j \lambda_j)

with

lambda_j ~ g()

with Mixture of Exponential:

g() = sum_k pi_k gamma(shape = 1, rate = b_k)

b_k is selected to cover the lambda_i of interest for all data points x_i

Usage

ebpm_gamma_mixture(
  x,
  s,
  shape,
  scale,
  g_init = NULL,
  fix_g = FALSE,
  m = 2,
  control = NULL,
  low = NULL
)

Arguments

x

A vector of Poisson observations.

s

A vector of scaling factors for Poisson observations: the model is y[j]~Pois(s[j]*lambda[j]).

shape

A vector specifying the shapes used in gamma mixtures

scale

A vector specifying the scales used in gamma mixtures

g_init

The prior distribution g, of the class gammamix. Usually this is left unspecified (NULL) and estimated from the data. However, it can be used in conjuction with fix_g = TRUE to fix the prior (useful, for example, to do computations with the "true" g in simulations). If g_init is specified but fix_g = FALSE, g_init specifies the initial value of g used during optimization.

fix_g

If TRUE, fix the prior g at g_init instead of estimating it.

m

multiple coefficient when selectig grid, so the b_k is of the form low*m^k-1; must be greater than 1; default is 2

control

A list of control parameters to be passed to the optimization function. 'mixsqp' is used.

Details

The model is fit in 2 stages: i) estimate g by maximum likelihood (over pi_k) ii) Compute posterior distributions for \lambda_j given x_j,\hat{g}.

Value

A list containing elements:

posterior

A data frame of summary results (posterior means, and posterior log mean).

fitted_g

The fitted prior \hat{g}, of class gammamix

log_likelihood

The optimal log likelihood attained L(\hat{g}).

Examples

   beta = c(rep(0,50),rexp(50))
   x = rpois(100,beta) # simulate Poisson observations
   s = replicate(100,1)
   m = 2
   out = ebpm::ebpm_gamma_mixture(x,s)
   

stephenslab/ebpm documentation built on Oct. 19, 2023, 1 p.m.