[R] Poisson Lognormal

Charles C. Berry cberry at tajo.ucsd.edu
Sat Mar 27 03:48:55 CET 2010


On Fri, 26 Mar 2010, Robert Ruser wrote:

> 2010/3/26 Charles C. Berry <cberry at tajo.ucsd.edu>:
>> On Fri, 26 Mar 2010, Robert Ruser wrote:
>> So this is the generalized linear model with a poisson family, log link, and
>> a Gaussian random effect in the linear predictor.
>>
>> Take a look at lme4, MASS (glmmPQL), and try searching CRAN packages for
>> 'glm' and 'GLM' (there are a bunch and several promise to handle random
>> effects, but YMMV).
>>
> Thank you. But I'm wondering how to set random effect? I have the data
> 'my.data':
> #n  number   count
> 1        0         252
> 2        1         163
> 3        2         120
> 4        3         95
> ............................
>
> number | exp(lambda) ~poisson(exp(lambda))
> exp(lambda)  ~  normal(a,b)
>
> probably I should use a formula:
>
> model.est <- glmer(number ~ 1, family = poisson(link="log"), data = my.data)
>
> but how to set random effect? I do not have predictors. Second I need
> to remember that for example 0 occurred 252 times. How to do it - I
> can do it using number = seq(number,times=count), but calculation will
> last longer.

So you have no clusters with more than one observation??

In that case glmer will complain and quit.

But what makes you think the extra-Poisson variation is indeed 
log-Normal??

If you accept that the extra-Poisson variation follows the Gamma 
distribution you can use MASS:::glm.nb. On the data you showed it runs 
'instantly' using

> y2 <- rep(0:3,c(252,163,120,95))
> grp2 <- factor(1:length(y2))
> fit2 <- glm.nb(y2~1/grp2)

and it fits a two parameter distribution, which is BTW is asymptotically 
log-normal (but I make no claim that those asymptotics apply here).

If you really need Poisson-logNormal, write a function that gives the 
probabilities of 0,...,k with k big enough to have vanishing probability 
for given (a,b) then minimize the difference between those values and the 
observed proportions using the Kullback-Liebler distance or the Pearson 
Chi-square w.r.t. (a,b).

HTH,

Chuck

>
> I would appreciate any help.
> Robert
>

Charles C. Berry                            (858) 534-2098
                                             Dept of Family/Preventive Medicine
E mailto:cberry at tajo.ucsd.edu	            UC San Diego
http://famprevmed.ucsd.edu/faculty/cberry/  La Jolla, San Diego 92093-0901



More information about the R-help mailing list