Dear all, I have a very basic question: how does the logLik function work for poisson models? Example: I simulate 20 observations from a Poisson distribution with mean 800. y <- rpois(20,800) model <- glm(y ~ 1, family=poisson()) logLik(model) I would like to know what's the exact formula the function logLik uses. I looked at ?extractAIC but I cannot sort it out. Can you please give me an help? Thanks a lot Antonio Gasparrini Public and Environmental Health Research Unit (PEHRU) London School of Hygiene & Tropical Medicine Keppel Street, London WC1E 7HT, UK Office: 0044 (0)20 79272406 - Mobile: 0044 (0)79 64925523 Skype contact: a.gasparrini http://www.lshtm.ac.uk/people/gasparrini.antonio ( http://www.lshtm.ac.uk/pehru/ )
Antonio, Given the model you used, the log link means you are modeling log(expected value of y)=intercept If you had an independent variable e.g. x model <- glm(y ~ x, family=poisson()) you would be modeling log(expected value of y)=intercept+x John John David Sorkin M.D., Ph.D. Chief, Biostatistics and Informatics University of Maryland School of Medicine Division of Gerontology Baltimore VA Medical Center 10 North Greene Street GRECC (BT/18/GR) Baltimore, MD 21201-1524 (Phone) 410-605-7119 (Fax) 410-605-7913 (Please call phone number above prior to faxing)>>> <Antonio.Gasparrini at lshtm.ac.uk> 2/1/2009 8:47 PM >>>Dear all, I have a very basic question: how does the logLik function work for poisson models? Example: I simulate 20 observations from a Poisson distribution with mean 800. y <- rpois(20,800) model <- glm(y ~ 1, family=poisson()) logLik(model) I would like to know what's the exact formula the function logLik uses. I looked at ?extractAIC but I cannot sort it out. Can you please give me an help? Thanks a lot Antonio Gasparrini Public and Environmental Health Research Unit (PEHRU) London School of Hygiene & Tropical Medicine Keppel Street, London WC1E 7HT, UK Office: 0044 (0)20 79272406 - Mobile: 0044 (0)79 64925523 Skype contact: a.gasparrini http://www.lshtm.ac.uk/people/gasparrini.antonio ( http://www.lshtm.ac.uk/pehru/ ) ______________________________________________ R-help at r-project.org 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. Confidentiality Statement: This email message, including any attachments, is for th...{{dropped:6}}
On Mon, 2 Feb 2009, Antonio.Gasparrini at lshtm.ac.uk wrote:> Dear all, > > I have a very basic question: > how does the logLik function work for poisson models?You mean its inner workings or just what is the computation? The computation is just the vanilla loglikelihood: sum( dpois( y, mean(y), log=TRUE) ) for your Poisson model. See ?dpois And for the inner workings, see stats:::logLik.glm poisson()$aic --- More generally, read the article Ligges, U. (2006): R Help Desk: Accessing the Sources. R News 6 (4), 43-45. http://cran.r-project.org/doc/Rnews/ HTH, Chuck> > Example: > I simulate 20 observations from a Poisson distribution with mean 800. > > y <- rpois(20,800) > model <- glm(y ~ 1, family=poisson()) > logLik(model) > > I would like to know what's the exact formula the function logLik uses. > I looked at ?extractAIC but I cannot sort it out. > > Can you please give me an help? > Thanks a lot > > Antonio Gasparrini > Public and Environmental Health Research Unit (PEHRU) > London School of Hygiene & Tropical Medicine > Keppel Street, London WC1E 7HT, UK > Office: 0044 (0)20 79272406 - Mobile: 0044 (0)79 64925523 > Skype contact: a.gasparrini > http://www.lshtm.ac.uk/people/gasparrini.antonio ( http://www.lshtm.ac.uk/pehru/ ) > > ______________________________________________ > R-help at r-project.org 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. >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