[R] Log-likelihood function

Ross Darnell r.darnell at uq.edu.au
Wed May 2 12:51:12 CEST 2007

Alternatively  generate the log-likelihood using the sum(dpois(y,
fitted(model), log = TRUE))


Ross Darnell

Doxastic wrote:
> You're right.  I do need to learn more.  I never learned null/residual
> deviance.  I know the deviance is equivalent to an anova decompostion. 
> But I've never dealt with it seperated like this.  
> I understand deviance as the difference between two model's log-likelihood
> difference between them and the most complex.  I want to compare two
> models that are not the most complex.  That is why I wanted the
> log-likelihood.  
> I am using the poisson distribution because my response is count data, so
> the link is the log.  If the deviance in R is computed by comparing the
> fitted model against the most saturated (which would make sense).  Then
> yes, I can use that.  I just picked the log-likelihood because I'm
> comparing two models.  And that's the best way.  But, it's equivalent if R
> compares the fitted to the most complex.
> I assumed the deviance print out tested the fitted model against the least
> complex.  This tests whether the current model parameters can be dropped
> (that's what I thought the null deviance meant).  I'm not sure what the
> residaul deviance means though.  
> My main concern is why the likelihood functions differed between SAS and
> R.  If anyone has encountered this or understands why, I would appreciate
> some help.
> Prof Brian Ripley wrote:
>> I think you need to learn about deviances, which R does print.
>> Log-likelihoods are only defined up to additive constants.  In this case 
>> the conventional constant differs if you view this as a Poisson or as a 
>> product-multinomial log-linear model, and R gives you the log-likelihood 
>> for a Poisson log-linear model (assuming you specified family=poisson). 
>> However, deviances and differences in log-likelihoods do not depend on 
>> which.
>> More details and worked examples can be found in MASS (the book, see the 
>> FAQ), including other ways to fit log-linear models in R.
>> On Tue, 1 May 2007, someone ashamed of his real name wrote:
>>> I've computed a loglinear model on a categorical dataset.  I would like
>>> to
>>> test whether an interaction can be dropped by comparing the
>>> log-likelihoods
>>> from two models(the model with the interaction vs. the model without).
>>> Since R does not immediately print the log-likelihood when I use the
>>> "glm"
>>> function, I used SAS initially.  After searching for an extracting
>>> function,
>>> I found one in R.  But, the log-likelihood given by SAS is different
>>> from
>>> the one given by R.  I'm not sure if the "logLik" function in R is
>>> giving me
>>> something I don't want.  Or if I'm misinterpreting the SAS output.  Can
>>> anyone help?
>> -- 
>> Brian D. Ripley,                  ripley at stats.ox.ac.uk
>> Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
>> University of Oxford,             Tel:  +44 1865 272861 (self)
>> 1 South Parks Road,                     +44 1865 272866 (PA)
>> Oxford OX1 3TG, UK                Fax:  +44 1865 272595
>> ______________________________________________
>> R-help at stat.math.ethz.ch mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide
>> http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.

View this message in context: http://www.nabble.com/Log-likelihood-function-tf3678882.html#a10283755
Sent from the R help mailing list archive at Nabble.com.

More information about the R-help mailing list