Re: Help with BUGS model



On Aug 22, 3:27 am, "sci.stat.math" <fra...@xxxxxxxx> wrote:
This is a quote from an article by W. DuMouchel et al. 1999 "BAYESIAN
DATA MINING IN LARGE FREQUENCY TABLES":
[Quote]:
... to achieve the interpretability of the relative risk measures but
also to adjust properly for sampling variation...Assume that each
observed count Nij is a draw from a Poisson distribution with unknown
mean mu[i], and that interest centers on the ratios lambda[i]= mu[i]/
E[i]. But rather than treat the M values of lambda[i] as unrelated
constants, assume that each lambda is drawn from a common prior
distribution. This distribution is assumed be a mixture of two gamma
distributions.
...the marginal distribution of each N is a mixture of negative
binomial distributions; and second, the
posterior distribution of each lambda is a mixture of two gamma
distributions with modified parameters:
Prob(N = n) = P f(n; a1, b1, E) + (1 - P) f(n; a2, b2, E)
with f(n; a, b, E) = (1 + b/E)^-n (1 + E/b)^-a Gamma(a + n) /
Gamma(a)n!
[End Quote]

I have is values of N and E. Now I have tried to perform it in winBUGS
using the model below that assumes lambda is drawn from one gamma
distribution (but not a mixture):

model
{
for (i in 1:K)
{
N[i]~ dpois( mu[i] )
mu[i]<- lambda[i]*E[i]
lambda[i] ~ dgamma( a, b )}

a ~dunif(0.000001, 100)
b ~ dunif(0.000001, 100 )

}

It works OK I can have an estimate of lambdas and the parameters a and
b but how can I modify my BUGS model to have lambdas drawn from the
mixture of two gamma distributions like the extract above states?
Thanks

This seems to work as an extension of your code:

model
{
for (i in 1:K)
{
Signal[i] <- mu[i]/E[i]
N[i]~ dpois( mu[i] )
mu[i]<- lambda[i]*E[i]
lambda[i] <-P*lambda1[i]+(1-P)*lambda2[i] #result of equation 4.
lambda1[i] ~ dgamma( a1, b1 )
lambda2[i] ~ dgamma( a2, b2 )
}

a1 ~dunif(0.000001, 100)
b1 ~ dunif(0.000001, 100 )
a2 ~dunif(0.001, 100)
b2 ~ dunif(0.001, 100 )
P~dbeta(10,100)}
}

#data
list(K=5, N=c(1,2,3,4,5), E=c(1,1,1,1,1) )

Note that to get Equation 7 of the DuMouchel paper (1999 American
Statistician), you have to put N in the data list. That is a trick in
WinBugs to get a posterior distribution since N is defined as a
stochastic node and as data. This makes the distribution of lambda
conditional on N. The data list above is just made up.

I added a signal node which is the MCMC distribution estimate of EBGM.
You can look at the posterior distribution of EBGM using the MCMC
sample. The mean of that distribution is the EBGM and the 5'th and
95'th percentiles are the credible region for EBGM.

DuMouchel advocates using MLE's for the estimates of a1, b1, a2, b2
and P, rather than as random hyperparameters, so you have departed
from the paper a little by letting them be random. Still, your
departure may be a neat extension. You could also add the MLE's of a1,
b1, a2, b2 and P to the data list, and leave them as stochastic nodes
to judge how uncertianty around the MLE's effect the posterior
distribution of the signal.

As an aside, I think that you will find your approach to be difficult
to implement in a production environment since you have to build the
data list with actual data for each data set. I guess you could use R
and BRUGS to manage it, but that would be a maintainance nightmare.

An advantage of your approach though is that you can extend the
definitions of lambda to loglinear models, which is a limitation in
the 1999 paper.

Mark

.



Relevant Pages

  • Re: On coverage probability of Confidence interval
    ... > because I know the underlying distribution, ... > of lambda through probability plot. ... > Using bootstrapping (Parametric type; since I know that it follows ... Now the issue is HOW to calculate the coverage ...
    (sci.stat.math)
  • Re: order statistics/life testing problem
    ... follow an exponential distribution with parameter ... Here lambda is the reciprocal of the mean. ... meaning the conditional expectation of the largest ... exponentials plus t*. ...
    (sci.stat.math)
  • Re: "Robbins lemma"?
    ... >If X is a random variable with a Poisson distribution with ... >expectation lambda, and g is any function for which the ... The way he used it was in a situation where lambda is ... If one is computing a Bayes estimate with squared error ...
    (sci.math.research)
  • Re: scalling of poisson distribution
    ... then the mean is lambda for period 2t ... I think that the fact that the distribution is discrete rather than ... dataset where a binomial distribution fit the data for healthcare visits ... Most "real data" regarding annual visits will have a ...
    (sci.stat.math)
  • Re: scalling of poisson distribution
    ... then the mean is lambda for period 2t ... I think that the fact that the distribution is discrete rather than ... dataset where a binomial distribution fit the data for healthcare visits ... Most "real data" regarding annual visits will have a ...
    (sci.stat.math)

Quantcast