R wont accept my zero count values in the GLM with quasi_poisson dsitribution

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

R wont accept my zero count values in the GLM with quasi_poisson dsitribution

Charlotte
Hello

I have count values for abundance which follow a pattern of over-dispersal with many zero values.  I have read a number of documents which suggest that I don't use data transforming methods but rather than I run the GLM with the quasi poisson distribution.  So I have written my script and R is telling me that Y should be more than 0.

Everything I read tells me to do it this way but I can't get R to agree.  Did I need to add something else to my script to get it to work and keep my data untransformed? The script I wrote is as follows:

> fit <- glm(abundance~Gender,data=teminfest,family=binomial())

then I get this error
Error in eval(expr, envir, enclos) : y values must be 0 <= y <= 1

I don't use R a lot so I am having trouble figuring out what to do next.

I would appreciate some help

Many Thanks
Charlotte


Reply | Threaded
Open this post in threaded view
|

Re: R wont accept my zero count values in the GLM with quasi_poisson dsitribution

Andrew Robinson-6
You have selected the binomial family in the call to glm.  You should
instead try something like

 family=quasipoisson(link = "log")

I hope this helps

Andrew

On Tue, Jul 28, 2015 at 4:33 PM, Charlotte <
[hidden email]> wrote:

> Hello
>
> I have count values for abundance which follow a pattern of over-dispersal
> with many zero values.  I have read a number of documents which suggest
> that
> I don't use data transforming methods but rather than I run the GLM with
> the
> quasi poisson distribution.  So I have written my script and R is telling
> me
> that Y should be more than 0.
>
> Everything I read tells me to do it this way but I can't get R to agree.
> Did I need to add something else to my script to get it to work and keep my
> data untransformed? The script I wrote is as follows:
>
> > fit <- glm(abundance~Gender,data=teminfest,family=binomial())
>
> then I get this error
> Error in eval(expr, envir, enclos) : y values must be 0 <= y <= 1
>
> I don't use R a lot so I am having trouble figuring out what to do next.
>
> I would appreciate some help
>
> Many Thanks
> Charlotte
>
>
>
>
>
>
> --
> View this message in context:
> http://r.789695.n4.nabble.com/R-wont-accept-my-zero-count-values-in-the-GLM-with-quasi-poisson-dsitribution-tp4710462.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> [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.
>



--
Andrew Robinson
Deputy Director, CEBRA, School of Biosciences
Reader & Associate Professor in Applied Statistics  Tel: (+61) 0403 138 955
School of Mathematics and Statistics                        Fax: +61-3-8344
4599
University of Melbourne, VIC 3010 Australia
Email: [hidden email]
Website: http://www.ms.unimelb.edu.au/~andrewpr

MSME: http://www.crcpress.com/product/isbn/9781439858028
FAwR: http://www.ms.unimelb.edu.au/~andrewpr/FAwR/
SPuR: http://www.ms.unimelb.edu.au/spuRs/

        [[alternative HTML version deleted]]

______________________________________________
[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: R wont accept my zero count values in the GLM with quasi_poisson dsitribution

Göran Broström-3
In reply to this post by Charlotte


On 28/07/15 08:33, Charlotte wrote:
> Hello
>
> I have count values for abundance which follow a pattern of
> over-dispersal with many zero values.  I have read a number of
> documents which suggest that I don't use data transforming methods
> but rather than I run the GLM with the quasi poisson distribution.
> So I have written my script and R is telling me that Y should be more
> than 0.

No,  R  is telling you that you must have 0 <= y <= 1 (see below).
For count data you should not use the binomial family, but rather
'poisson', or 'quasipoisson'.

?family

Göran

> Everything I read tells me to do it this way but I can't get R to
> agree. Did I need to add something else to my script to get it to
> work and keep my data untransformed? The script I wrote is as
> follows:
>
>> fit <- glm(abundance~Gender,data=teminfest,family=binomial())
>
> then I get this error Error in eval(expr, envir, enclos) : y values
> must be 0 <= y <= 1
>
> I don't use R a lot so I am having trouble figuring out what to do
> next.
>
> I would appreciate some help
>
> Many Thanks Charlotte
>
>
>
>
>
>
> -- View this message in context:
> http://r.789695.n4.nabble.com/R-wont-accept-my-zero-count-values-in-the-GLM-with-quasi-poisson-dsitribution-tp4710462.html
>
>
Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________ [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: R wont accept my zero count values in the GLM with quasi_poisson dsitribution

John Maindonald
In reply to this post by Charlotte
A further point to note is that with a log link, SEs for comparisons with any factor
level where counts are all zero will be huge and meaningless.  This phenomenon
has the name Hauck-Donner effect, though more commonly so identified for
comparisons with categories with very low or very high estimated proportions
for binomial data.  For the poisson or quasipoisson family, use of the sqrt link
avoids this problem.


John Maindonald             email: [hidden email]<mailto:[hidden email]>


On 28/07/2015, at 22:00, [hidden email]<mailto:[hidden email]> wrote:

From: Andrew Robinson <[hidden email]<mailto:[hidden email]>>
Subject: Re: [R] R wont accept my zero count values in the GLM with quasi_poisson dsitribution
Date: 28 July 2015 18:59:51 NZST
To: Charlotte <[hidden email]<mailto:[hidden email]>>
Cc: "R help ([hidden email]<mailto:[hidden email]>)" <[hidden email]<mailto:[hidden email]>>


You have selected the binomial family in the call to glm.  You should
instead try something like

family=quasipoisson(link = "log")

I hope this helps

Andrew

On Tue, Jul 28, 2015 at 4:33 PM, Charlotte <
[hidden email]<mailto:[hidden email]>> wrote:

Hello

I have count values for abundance which follow a pattern of over-dispersal
with many zero values.  I have read a number of documents which suggest
that
I don't use data transforming methods but rather than I run the GLM with
the
quasi poisson distribution.  So I have written my script and R is telling
me
that Y should be more than 0.

Everything I read tells me to do it this way but I can't get R to agree.
Did I need to add something else to my script to get it to work and keep my
data untransformed? The script I wrote is as follows:

fit <- glm(abundance~Gender,data=teminfest,family=binomial())

then I get this error
Error in eval(expr, envir, enclos) : y values must be 0 <= y <= 1

I don't use R a lot so I am having trouble figuring out what to do next.

I would appreciate some help

Many Thanks
Charlotte






--
View this message in context:
http://r.789695.n4.nabble.com/R-wont-accept-my-zero-count-values-in-the-GLM-with-quasi-poisson-dsitribution-tp4710462.html
Sent from the R help mailing list archive at Nabble.com<http://nabble.com/>.

______________________________________________
[hidden email]<mailto:[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<http://www.r-project.org/posting-guide.html>
and provide commented, minimal, self-contained, reproducible code.




--
Andrew Robinson
Deputy Director, CEBRA, School of Biosciences
Reader & Associate Professor in Applied Statistics  Tel: (+61) 0403 138 955
School of Mathematics and Statistics                        Fax: +61-3-8344
4599
University of Melbourne, VIC 3010 Australia
Email: [hidden email]<mailto:[hidden email]>
Website: http://www.ms.unimelb.edu.au/~andrewpr

MSME: http://www.crcpress.com/product/isbn/9781439858028
FAwR: http://www.ms.unimelb.edu.au/~andrewpr/FAwR/
SPuR: http://www.ms.unimelb.edu.au/spuRs/


        [[alternative HTML version deleted]]

______________________________________________
[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: R wont accept my zero count values in the GLM with quasi_poisson dsitribution

Michael Friendly
In reply to this post by Göran Broström-3
On 7/28/2015 3:05 AM, Göran Broström wrote:

>
>
> On 28/07/15 08:33, Charlotte wrote:
>> Hello
>>
>> I have count values for abundance which follow a pattern of
>> over-dispersal with many zero values.  I have read a number of
>> documents which suggest that I don't use data transforming methods
>> but rather than I run the GLM with the quasi poisson distribution.
>> So I have written my script and R is telling me that Y should be more
>> than 0.
>
> No,  R  is telling you that you must have 0 <= y <= 1 (see below).
> For count data you should not use the binomial family, but rather
> 'poisson', or 'quasipoisson'.


With excess zeros, overdispersion is the symptom, but the quasipoisson
model is not the cure.
Even better than quasipoisson would be to use a ZIP (zero-inflated
poisson) model or a hurdle model to explicitly model the
excess zeros.

These are handled by the countreg package, at present only
available on R-Forge.

  install.packages("countreg", repos="http://R-Forge.R-project.org")


>
>> ______________________________________________ [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: R wont accept my zero count values in the GLM with quasi_poisson dsitribution

Charlotte
Hello

I am going to look at the ZIP (zero-inflated poisson).  I just need to ask.  One of my variables is continuous data (hosts body length), is it ok to include this kind of data into this analysis or do I need to turn it into categories (29-50 mm, 51-100mm and so on)?

Many Thanks
Charlotte
Reply | Threaded
Open this post in threaded view
|

Re: R wont accept my zero count values in the GLM with quasi_poisson dsitribution

Wensui Liu
In reply to this post by Charlotte
based on your code "fit <-
glm(abundance~Gender,data=teminfest,family=binomial())", i don't see
anything related to quasi_poisson. are you sure what you are doing
here?

On Tue, Jul 28, 2015 at 1:33 AM, Charlotte
<[hidden email]> wrote:

> Hello
>
> I have count values for abundance which follow a pattern of over-dispersal
> with many zero values.  I have read a number of documents which suggest that
> I don't use data transforming methods but rather than I run the GLM with the
> quasi poisson distribution.  So I have written my script and R is telling me
> that Y should be more than 0.
>
> Everything I read tells me to do it this way but I can't get R to agree.
> Did I need to add something else to my script to get it to work and keep my
> data untransformed? The script I wrote is as follows:
>
>> fit <- glm(abundance~Gender,data=teminfest,family=binomial())
>
> then I get this error
> Error in eval(expr, envir, enclos) : y values must be 0 <= y <= 1
>
> I don't use R a lot so I am having trouble figuring out what to do next.
>
> I would appreciate some help
>
> Many Thanks
> Charlotte
>
>
>
>
>
>
> --
> View this message in context: http://r.789695.n4.nabble.com/R-wont-accept-my-zero-count-values-in-the-GLM-with-quasi-poisson-dsitribution-tp4710462.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> [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.



--
WenSui Liu
https://statcompute.wordpress.com/

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