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 in different formats just in case. Thanks in advanced, Joaqu?n. -- *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)
> On Aug 19, 2015, at 8:54 AM, Joaqu?n Aldabe <joaquin.aldabe at gmail.com> wrote: > > 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 in different formats just in case.The script in .txt format was accepted by the server. The data was apparently not in a .txt format, so it was rejected. You made three plots, so when you reply with data using the correct format (which is plain text and generally need to have an extension .txt so that mail client will lable as MIME-text) , you should be more specific about which plots are not exhibiting the expected features. I noticed you made two data-frames, ?my4s' and ?my4S'. The `my4S` was built with `cbind` which would create a matrix (probably a character matrix) rather than a data frame. I?m wondering you you inadvertently constructed a data-object whose structure was different than you imagined? It might have gotten coerced back to a dataframe with undesirable concsequences. ? David.> > Thanks in advanced, > > Joaqu?n. > > > -- > *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> > <glm forum consult.txt>______________________________________________ > R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see > 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.
Inline. Cheers, Bert Bert Gunter "Data is not information. Information is not knowledge. And knowledge is certainly not wisdom." -- Clifford Stoll On Thu, Aug 20, 2015 at 9:06 PM, David Winsemius <dwinsemius at comcast.net> wrote:> >> On Aug 19, 2015, at 8:54 AM, Joaqu?n Aldabe <joaquin.aldabe at gmail.com> wrote: >> >> 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 in different formats just in case. > > The script in .txt format was accepted by the server. The data was apparently not in a .txt format, so it was rejected. > > You made three plots, so when you reply with data using the correct format (which is plain text and generally need to have an extension .txt so that mail client will lable as MIME-text) , you should be more specific about which plots are not exhibiting the expected features. > > I noticed you made two data-frames, ?my4s' and ?my4S'. The `my4S` was built with `cbind` which would create a matrix (probably a character matrix) rather than a data frame.False. There is a data.frame method for cbind that returns a data frame. Don't know the specifics here, though. Cheers, Bert I?m wondering you you inadvertently constructed a data-object whose structure was different than you imagined? It might have gotten coerced back to a dataframe with undesirable concsequences.> > ? > David. > >> >> Thanks in advanced, >> >> Joaqu?n. >> >> >> -- >> *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> >> <glm forum consult.txt>______________________________________________ >> R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see >> 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. > > ______________________________________________ > R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see > 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.
Thankyou all by the comments and sorry for not sending in the adequate format. I don't have the chance to make txt archives as open office doesn't do it. I'm attaching the data in excel. Please let me know if this is ok. The graph that is wierd to me is the BBSA vs AMGP. It is supposed that AMGP has a positive effect on BBSA, but the model fit shows a negative slope. In other forum I was told to plot each variable with fixed values of the other two variables, and make different curves for each variable. Thanks again for your interest and help. All the best, Joaqu?n 2015-08-19 12:54 GMT-03: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 in different formats just in case. > > Thanks in advanced, > > Joaqu?n. > > > -- > *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> > >-- *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>
Thanks. Here is in csv format. Cheers, Joaqu?n. 2015-08-21 12:49 GMT-03:00 Don McKenzie <dmck at uw.edu>:> You can save to .csv from OpenOffice. > > Sent from my iPad > > > On Aug 21, 2015, at 4:45 AM, Joaqu?n Aldabe <joaquin.aldabe at gmail.com> > wrote: > > > > Thankyou all by the comments and sorry for not sending in the adequate > > format. I don't have the chance to make txt archives as open office > doesn't > > do it. I'm attaching the data in excel. Please let me know if this is ok. > > > > The graph that is wierd to me is the BBSA vs AMGP. It is supposed that > AMGP > > has a positive effect on BBSA, but the model fit shows a negative slope. > In > > other forum I was told to plot each variable with fixed values of the > other > > two variables, and make different curves for each variable. > > > > Thanks again for your interest and help. > > > > All the best, > > Joaqu?n > > > > 2015-08-19 12:54 GMT-03: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 in different formats just in case. > >> > >> Thanks in advanced, > >> > >> Joaqu?n. > >> > >> > >> -- > >> *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> > >> > >> > > > > > > -- > > *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-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see > > 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. >-- *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>
.csv format is still not accepted by the server. When I say it needs to be a .txt file .... I mean it it needs to be a .txt file. You need to change its extension to .txt to prevent your mail client from labeling it as csv which is a different type even though I, too, would have thought they should both be accepted. I do now see that the last argument to cbind was a dataframe and Bert's comments there were correct. I did not see that tiny little `my4s` way out at at the end of all those other arguments. -- David. On Aug 21, 2015, at 10:06 AM, Joaqu?n Aldabe wrote:> Thanks. Here is in csv format. > Cheers, > Joaqu?n. > > 2015-08-21 12:49 GMT-03:00 Don McKenzie <dmck at uw.edu>: > >> You can save to .csv from OpenOffice. >> >> Sent from my iPad >> >>> On Aug 21, 2015, at 4:45 AM, Joaqu?n Aldabe <joaquin.aldabe at gmail.com> >> wrote: >>> >>> Thankyou all by the comments and sorry for not sending in the adequate >>> format. I don't have the chance to make txt archives as open office >> doesn't >>> do it. I'm attaching the data in excel. Please let me know if this is ok. >>> >>> The graph that is wierd to me is the BBSA vs AMGP. It is supposed that >> AMGP >>> has a positive effect on BBSA, but the model fit shows a negative slope. >> In >>> other forum I was told to plot each variable with fixed values of the >> other >>> two variables, and make different curves for each variable. >>> >>> Thanks again for your interest and help. >>> >>> All the best, >>> Joaqu?n >>> >>> 2015-08-19 12:54 GMT-03: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 in different formats just in case. >>>> >>>> Thanks in advanced, >>>> >>>> Joaqu?n. >>>> >>>> >>>> -- >>>> *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> >>>> >>>> >>> >>> >>> -- >>> *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-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see >>> 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. >> > > > > -- > *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-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see > 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 Alameda, CA, USA