[R] accessing log likelihood of poison model
cheney at soc.umass.edu
Sun Apr 18 02:31:10 CEST 2004
On Sunday, 18 April 2004 at 0:52:19 +0200, Peter Dalgaard wrote:
> Eric Cheney <cheney at soc.umass.edu> writes:
> > Could someone tell me how to access the log likelihood
> > of a poisson model? I've done the following....
> > <BEGIN R STUFF>
> > freq.mod <- glm(formula = nfix ~ gls.gls + pol.gls + pol.rel + rac.gls +
> > rac.pol + rac.rac + rac.rel + white + gls.gls.w + pol.gls.w + pol.rel.w
> > + rac.gls.w + rac.pol.w + rac.rac.w + rac.rac.w + rac.rel.w, family =
> > poisson, data = Complex2.freq, offset = lnoffset)
> > summary(freq.mod)
> > anova(freq.mod)
> > <END R STUFF>
> > And that's great; but I need the log likelihood.
> > Anyone know?
> The deviance will not suffice?
> sum(dpois(nfix, fitted(freq.mod), log.p=T))
> should do the trick otherwise.
Thank you, that did the trick. I should note that the method doesn't
work when I have a noninteger in Y. I'm doing a "log linear" analysis
of a cross table, and one of the cells of the cross table has a zero
value. I put a .5 in that cell. With the ".5 analysis" the above
method doesn't work. So I had to revert to an analysis with a zero
cell to make it work. Which has some problems. So I'm still left
looking for the log likelihood of the ".5 analysis". I've had success
with Stata using this method, but not R.
<Eric Cheney> cheney at soc.umass.edu http://sociostat.org/eric/
More information about the R-help