Dear R helpers, running the following code of a glm model of the family poisson, gives predicted values < 0. Why? library(MASS) library(stats) library(mvtnorm) library(pscl) data(bioChemists) poisson_glm <- glm(art ~ fem + mar + kid5 + phd + ment, data = bioChemists, family = poisson) predicted.values = predict(poisson_glm) range(predicted.values) Thank you in advance for any hints. Best regards, P. Olsson [[alternative HTML version deleted]]
On Wed, 18 Jan 2006, P. Olsson wrote:> Dear R helpers, > running the following code of a glm model of the family poisson, gives > predicted values < 0. Why?Look at the help page for predict.glm, particularly the "type" argument. Then exponentiate the results. -thomas> > library(MASS) > library(stats) > library(mvtnorm) > library(pscl) > data(bioChemists) > poisson_glm <- glm(art ~ fem + mar + kid5 + phd + ment, data = bioChemists, > family = poisson) > predicted.values = predict(poisson_glm) > range(predicted.values) > > > Thank you in advance for any hints. > Best regards, > P. Olsson > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help at stat.math.ethz.ch mailing list > stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide! R-project.org/posting-guide.html >Thomas Lumley Assoc. Professor, Biostatistics tlumley at u.washington.edu University of Washington, Seattle
"P. Olsson" <olsson1 at gmail.com> writes:> Dear R helpers, > running the following code of a glm model of the family poisson, gives > predicted values < 0. Why? > > library(MASS) > library(stats) > library(mvtnorm) > library(pscl) > data(bioChemists) > poisson_glm <- glm(art ~ fem + mar + kid5 + phd + ment, data = bioChemists, > family = poisson) > predicted.values = predict(poisson_glm) > range(predicted.values) > > > Thank you in advance for any hints.The prediction is on the link scale. -- O__ ---- Peter Dalgaard ??ster Farimagsgade 5, Entr.B c/ /'_ --- Dept. of Biostatistics PO Box 2099, 1014 Cph. K (*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918 ~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk) FAX: (+45) 35327907
P. Olsson <olsson1 <at> gmail.com> writes:> > Dear R helpers, > running the following code of a glm model of the family poisson, gives > predicted values < 0. Why? >Because by default predict.glm() gives answers on the link (log) scale. predict(poisson_glm,type="response") is probably what you're looking for. See ?predict.glm. Ben Bolker
On Wed, 18 Jan 2006 14:58:26 +0100, P. Olsson wrote: PO> Dear R helpers, PO> running the following code of a glm model of the family poisson, PO> gives predicted values < 0. Why? PO> PO> library(MASS) PO> library(stats) PO> library(mvtnorm) PO> library(pscl) PO> data(bioChemists) PO> poisson_glm <- glm(art ~ fem + mar + kid5 + phd + ment, data PO> bioChemists, family = poisson) PO> predicted.values = predict(poisson_glm) PO> range(predicted.values) PO> use predicted.values = predict(poisson_glm, type="response") best wishes, Adelchi Azzalini <azzalini at stat.unipd.it> Dipart.Scienze Statistiche, Universit?? di Padova, Italia tel. +39 049 8274147, azzalini.stat.unipd.it