glm help

classic Classic list List threaded Threaded
10 messages Options
Reply | Threaded
Open this post in threaded view
|

glm help

Joaquín Aldabe
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>

______________________________________________
[hidden email] 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.

glm forum consult.txt (1K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: glm help

1Rnwb
This post has NOT been accepted by the mailing list yet.
post a working sample of the analysis.
Reply | Threaded
Open this post in threaded view
|

Re: glm help

David Winsemius
In reply to this post by Joaquín Aldabe

> On Aug 19, 2015, at 8:54 AM, Joaquín Aldabe <[hidden email]> 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>______________________________________________
> [hidden email] 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.

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: glm help

Bert Gunter-2
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 <[hidden email]> wrote:

>
>> On Aug 19, 2015, at 8:54 AM, Joaquín Aldabe <[hidden email]> 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>______________________________________________
>> [hidden email] 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.
>
> ______________________________________________
> [hidden email] 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.

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: glm help

plangfelder
On Thu, Aug 20, 2015 at 10:04 PM, Bert Gunter <[hidden email]> wrote:

>> 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.
>

True, but does not apply here, i.e., David is correct. cbind will
return a data frame if the first argument is a data frame. In the OP
case, the first argument was a vector and hence cbind gives a matrix,
of mode "character" if any of the inputs were character. Here's a
short demo:

> a = data.frame(a1 = 1:10)
# First argument a data frame, so the results is also a data frame  :
> class(cbind(a, b = 11:20))
[1] "data.frame"
# First argument is a vector, so the result is a matrix:
> class(cbind(a$a1, b = 11:20))
[1] "matrix"
> mode(cbind(a$a1, b = 11:20))
[1] "numeric"
> mode(cbind(a$a1, b = letters[11:20]))
[1] "character"

Peter

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: glm help

Joaquín Aldabe
In reply to this post by Joaquín Aldabe
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 <[hidden email]>:

> 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>
______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: glm help

Bert Gunter-2
In reply to this post by plangfelder
Inline.

-- 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 10:47 PM, Peter Langfelder
<[hidden email]> wrote:

> On Thu, Aug 20, 2015 at 10:04 PM, Bert Gunter <[hidden email]> wrote:
>
>>> 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.
>>
>
> True, but does not apply here, i.e., David is correct. cbind will
> return a data frame if the first argument is a data frame. In the OP
> case, the first argument was a vector and hence cbind gives a matrix,

False again.

class(cbind(a=1:5,b=data.frame(a=letters[1:5],b=3:7)))

[1] "data.frame"

##First argument a vector, but data frame is returned. Please consult
?cbind -- especially the data frame section -- for details.

Again, I don't know the specifics here, and you and David may still
well be right for what the OP did. I am only trying to correct what
appear to me to be incorrect statements about the data.frame method of
cbind (or rbind). Apologies if I have misinterpreted.

Cheers,
Bert



> of mode "character" if any of the inputs were character. Here's a
> short demo:
>
>> a = data.frame(a1 = 1:10)
> # First argument a data frame, so the results is also a data frame  :
>> class(cbind(a, b = 11:20))
> [1] "data.frame"
> # First argument is a vector, so the result is a matrix:
>> class(cbind(a$a1, b = 11:20))
> [1] "matrix"
>> mode(cbind(a$a1, b = 11:20))
> [1] "numeric"
>> mode(cbind(a$a1, b = letters[11:20]))
> [1] "character"
>
> Peter

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: glm help

plangfelder
Thanks for the correction, I learned something new.

Peter

On Fri, Aug 21, 2015 at 7:32 AM, Bert Gunter <[hidden email]> wrote:

> Inline.
>
> -- 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 10:47 PM, Peter Langfelder
> <[hidden email]> wrote:
>> On Thu, Aug 20, 2015 at 10:04 PM, Bert Gunter <[hidden email]> wrote:
>>
>>>> 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.
>>>
>>
>> True, but does not apply here, i.e., David is correct. cbind will
>> return a data frame if the first argument is a data frame. In the OP
>> case, the first argument was a vector and hence cbind gives a matrix,
>
> False again.
>
> class(cbind(a=1:5,b=data.frame(a=letters[1:5],b=3:7)))
>
> [1] "data.frame"
>
> ##First argument a vector, but data frame is returned. Please consult
> ?cbind -- especially the data frame section -- for details.
>
> Again, I don't know the specifics here, and you and David may still
> well be right for what the OP did. I am only trying to correct what
> appear to me to be incorrect statements about the data.frame method of
> cbind (or rbind). Apologies if I have misinterpreted.
>
> Cheers,
> Bert
>
>
>
>> of mode "character" if any of the inputs were character. Here's a
>> short demo:
>>
>>> a = data.frame(a1 = 1:10)
>> # First argument a data frame, so the results is also a data frame  :
>>> class(cbind(a, b = 11:20))
>> [1] "data.frame"
>> # First argument is a vector, so the result is a matrix:
>>> class(cbind(a$a1, b = 11:20))
>> [1] "matrix"
>>> mode(cbind(a$a1, b = 11:20))
>> [1] "numeric"
>>> mode(cbind(a$a1, b = letters[11:20]))
>> [1] "character"
>>
>> Peter

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: glm help

Joaquín Aldabe
In reply to this post by Joaquín Aldabe
Thanks. Here is in csv format.
Cheers,
Joaquín.

2015-08-21 12:49 GMT-03:00 Don McKenzie <[hidden email]>:

> You can save to .csv from OpenOffice.
>
> Sent from my iPad
>
> > On Aug 21, 2015, at 4:45 AM, Joaquín Aldabe <[hidden email]>
> 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 <[hidden email]>:
> >
> >> 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>
> > ______________________________________________
> > [hidden email] 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>
______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: glm help

David Winsemius
.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 <[hidden email]>:
>
>> You can save to .csv from OpenOffice.
>>
>> Sent from my iPad
>>
>>> On Aug 21, 2015, at 4:45 AM, Joaquín Aldabe <[hidden email]>
>> 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 <[hidden email]>:
>>>
>>>> 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>
>>> ______________________________________________
>>> [hidden email] 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>
> ______________________________________________
> [hidden email] 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

______________________________________________
[hidden email] 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.