glm question
Thanks Thierry, I?ve attached the data in excel format and the script in txt. I?ll also write to r-help. Best wishes, Joaqu?n. 2015-08-19 11:54 GMT-03:00 Thierry Onkelinx <thierry.onkelinx at inbo.be>:
Dear Joaquin, Your attachments got stripped. It's better to put them somewhere on line an add a link in your message. If your problem concerns a glm() then r-help would be a better mailing list. If it is about glmer() then this mailing list is fine. Best regards, ir. Thierry Onkelinx Instituut voor natuur- en bosonderzoek / Research Institute for Nature and Forest team Biometrie & Kwaliteitszorg / team Biometrics & Quality Assurance Kliniekstraat 25 1070 Anderlecht Belgium To call in the statistician after the experiment is done may be no more than asking him to perform a post-mortem examination: he may be able to say what the experiment died of. ~ Sir Ronald Aylmer Fisher The plural of anecdote is not data. ~ Roger Brinner The combination of some data and an aching desire for an answer does not ensure that a reasonable answer can be extracted from a given body of data. ~ John Tukey 2015-08-19 16:39 GMT+02:00 Joaqu?n Aldabe <joaquin.aldabe at gmail.com>:
Dear All, I?m running a glm with poisson errors and have a doubt when ploting the predicted values. One of my variables has a positive slope in the summary output, but when I plot the predicted values on the original plot it draws a line with negative slope. I appreciate your comments on this and any other aspect of the analysis. Attached is the script and data. Thanks in advanced, Joaqu?n. pd. If this is not the correct forum to ask about glm, please let me
know.
-- *Joaqu?n Aldabe* *Grupo Biodiversidad, Ambiente y Sociedad* Centro Universitario de la Regi?n Este, Universidad de la Rep?blica Ruta 15 (y Ruta 9), Km 28.500, Departamento de Rocha *Departamento de Conservaci?n* Aves Uruguay BirdLife International Canelones 1164, Montevideo https://sites.google.com/site/joaquin.aldabe <https://sites.google.com/site/perfilprofesionaljoaquinaldabe>
_______________________________________________ R-sig-mixed-models at r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-sig-mixed-models
*Joaqu?n Aldabe* *Grupo Biodiversidad, Ambiente y Sociedad* Centro Universitario de la Regi?n Este, Universidad de la Rep?blica Ruta 15 (y Ruta 9), Km 28.500, Departamento de Rocha *Departamento de Conservaci?n* Aves Uruguay BirdLife International Canelones 1164, Montevideo https://sites.google.com/site/joaquin.aldabe <https://sites.google.com/site/perfilprofesionaljoaquinaldabe> -------------- next part -------------- my4<-read.table(file.choose(), header=T, dec=",") my4s<-as.data.frame(scale(my4[,c(6,10,12,13,16)], center=T, scale=T)) my4S<-cbind(BBSA=my4$BBSA, Field_name=my4$Field_name,Grassland_type=my4$Grassland_type, Flood=my4$Flood, Year=my4$Year,my4s) m2.glm=glm(BBSA~AMGP+Distance_to_lagoon+Grass_height, family="quasipoisson", data=my4S summary(m2.glm) #residuales par(mfrow=c(2,2)) plot(m2.glm)#pretty good #predict amgp=seq(-0.51, 5.44, length.out=100) grass=seq(-0.85,2.83, length.out=100) dist=seq(-1.59,1.53, length.out=100) newdata=data.frame(AMGP=amgp, Distance_to_lagoon=dist,Grass_height=grass) pred.m2.glm=exp(predict(m2.glm,newdata)) plot(BBSA~Grass_height, data=my4S) lines(newdata$Grass_height,pred.m2.glm) plot(BBSA~AMGP, data=my4S) lines(newdata$AMGP,pred.m2.glm)#why negative slope if summary output is positive plot(BBSA~Distance_to_lagoon, data=my4S) lines(newdata$Distance_to_lagoon, pred.m2.glm)