Corrado
2010-Mar-30 14:51 UTC
[R] From THE R BOOK -> Warning: In eval(expr, envir, enclos) : non-integer #successes in a binomial glm!
Dear friends, I am testing glm as at page 514/515 of THE R BOOK by M.Crawley, that is on proportion data. I use glm(y~x1+,family=binomial) y is a proportion in (0,1), and x is a real number. I get the error: In eval(expr, envir, enclos) : non-integer #successes in a binomial glm! But that is exactly what was suggested in the book, where there is no mention of a similar warning. Where am I going wrong? Here is the output: > glm(response.prepared~x,data=dddd,family=binomial) Call: glm(formula = response.prepared ~ x, family = binomial, data = dddd) Coefficients: (Intercept) x -0.3603 0.4480 Degrees of Freedom: 510554 Total (i.e. Null); 510553 Residual Null Deviance: 24420 Residual Deviance: 23240 AIC: 700700 Warning message: In eval(expr, envir, enclos) : non-integer #successes in a binomial glm! > Regards -- Corrado Topi PhD Researcher Global Climate Change and Biodiversity Area 18,Department of Biology University of York, York, YO10 5YW, UK Phone: + 44 (0) 1904 328645, E-mail: ct529 at york.ac.uk
Rubén Roa
2010-Mar-30 15:02 UTC
[R] From THE R BOOK -> Warning: In eval(expr, envir, enclos) : non-integer #successes in a binomial glm!
-----Mensaje original----- De: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org] En nombre de Corrado Enviado el: martes, 30 de marzo de 2010 16:52 Para: r-help at r-project.org Asunto: [R] From THE R BOOK -> Warning: In eval(expr, envir, enclos) : non-integer #successes in a binomial glm! Dear friends, I am testing glm as at page 514/515 of THE R BOOK by M.Crawley, that is on proportion data. I use glm(y~x1+,family=binomial) y is a proportion in (0,1), and x is a real number. I get the error: In eval(expr, envir, enclos) : non-integer #successes in a binomial glm! But that is exactly what was suggested in the book, where there is no mention of a similar warning. Where am I going wrong? Here is the output: > glm(response.prepared~x,data=dddd,family=binomial) Call: glm(formula = response.prepared ~ x, family = binomial, data = dddd) Coefficients: (Intercept) x -0.3603 0.4480 Degrees of Freedom: 510554 Total (i.e. Null); 510553 Residual Null Deviance: 24420 Residual Deviance: 23240 AIC: 700700 Warning message: In eval(expr, envir, enclos) : non-integer #successes in a binomial glm! > Regards -- Corrado Topi PhD Researcher Global Climate Change and Biodiversity Area 18,Department of Biology University of York, York, YO10 5YW, UK Phone: + 44 (0) 1904 328645, E-mail: ct529 at york.ac.uk --- Probably you are misreading Crawley's Book? A proportion would usually be modeled with the Beta distribution, not the binomial, which is for counts. If you are modeling a proportion try the betareg function in betareg package. HTH Ruben ____________________________________________________________________________________ Dr. Rub?n Roa-Ureta AZTI - Tecnalia / Marine Research Unit Txatxarramendi Ugartea z/g 48395 Sukarrieta (Bizkaia) SPAIN
David Winsemius
2010-Mar-30 15:04 UTC
[R] From THE R BOOK -> Warning: In eval(expr, envir, enclos) : non-integer #successes in a binomial glm!
A) It is not an error, only a warning. Wouldn't it seem reasonable to issue such a warning if you have data that violates the distributional assumptions? B) You did not include any of the data C) Wouldn't this be more appropriate to the author of the book if this is "exactly what was suggested" there? -- David, On Mar 30, 2010, at 10:51 AM, Corrado wrote:> Dear friends, > > I am testing glm as at page 514/515 of THE R BOOK by M.Crawley, that > is on proportion data. > > I use glm(y~x1+,family=binomial) > > y is a proportion in (0,1), and x is a real number. > > I get the error: > > In eval(expr, envir, enclos) : non-integer #successes in a binomial > glm! > > But that is exactly what was suggested in the book, where there is > no mention of a similar warning. Where am I going wrong? > > Here is the output: > > > glm(response.prepared~x,data=dddd,family=binomial) > > Call: glm(formula = response.prepared ~ x, family = binomial, data > = dddd) > > Coefficients: > (Intercept) x -0.3603 0.4480 > Degrees of Freedom: 510554 Total (i.e. Null); 510553 Residual > Null Deviance: 24420 > Residual Deviance: 23240 AIC: 700700 > Warning message: > In eval(expr, envir, enclos) : non-integer #successes in a binomial > glm! > > > > > > Regards > -- > > Corrado Topi > PhD Researcher > Global Climate Change and Biodiversity > Area 18,Department of Biology > University of York, York, YO10 5YW, UK > Phone: + 44 (0) 1904 328645, E-mail: ct529 at york.ac.uk > > ______________________________________________ > 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.David Winsemius, MD West Hartford, CT
Yihui Xie
2010-Mar-30 15:12 UTC
[R] From THE R BOOK -> Warning: In eval(expr, envir, enclos) : non-integer #successes in a binomial glm!
In a Binomial GLM, typically y is a factor with two levels (indicating success/failure) instead of a numeric vector on [0, 1]. Perhaps the description in the book is not so clear. You should interpret "data on proportions" as the observations from a Binomial distribution (rather than we observed some proportion data which fell in [0,1]). E.g. y=rbinom(10, size = 1, prob = .3); x=rnorm(y) # or y = factor(y) glm(y~x, family = binomial) Regards, Yihui -- Yihui Xie <xieyihui at gmail.com> Phone: 515-294-6609 Web: http://yihui.name Department of Statistics, Iowa State University 3211 Snedecor Hall, Ames, IA On Tue, Mar 30, 2010 at 9:51 AM, Corrado <ct529 at york.ac.uk> wrote:> Dear friends, > > I am testing glm as at page 514/515 of THE R BOOK by M.Crawley, that is on > proportion data. > > I use glm(y~x1+,family=binomial) > > y is a proportion in (0,1), and x is a real number. > > I get the error: > > In eval(expr, envir, enclos) : non-integer #successes in a binomial glm! > > But that is exactly what was suggested in the book, where there is no > mention of a similar warning. Where am I going wrong? > > Here is the output: > >> glm(response.prepared~x,data=dddd,family=binomial) > > Call: ?glm(formula = response.prepared ~ x, family = binomial, data = dddd) > > Coefficients: > (Intercept) ? ? ? ? ? ?x ? ?-0.3603 ? ? ? 0.4480 > Degrees of Freedom: 510554 Total (i.e. Null); ?510553 Residual > Null Deviance: ? ? ?24420 > Residual Deviance: 23240 ? ? ? ?AIC: 700700 > Warning message: > In eval(expr, envir, enclos) : non-integer #successes in a binomial glm! >> > > > > Regards > -- > > Corrado Topi > PhD Researcher > Global Climate Change and Biodiversity > Area 18,Department of Biology > University of York, York, YO10 5YW, UK > Phone: + 44 (0) 1904 328645, E-mail: ct529 at york.ac.uk > > ______________________________________________ > 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. >