3 Feb 21:01
Re: Low counts
I analyze a lot of count data and have had good results with negative
binomial models too. The other day I made some very* *crude code to help me
figure out which count-type distribution is most suitable. It plots a cum
freq dist for the data, then cfd's for random poisson(green) and neg.
binomial (red) datasets with the same means and dispersions.
You could add code for zero-inflated poisson and others in there if you want
to compare those. I couldn't figure out how to put continuous curves on the
graph, hence the discrete curves on the "idealized" cdf's instead of nice
smooth curves. The data used below are some worms we counted and some
meaningless veg plot data I happened to have on the same locations...you
could obviously just replace my file/object/factor names with yours.
Take this with the disclaimer that I might not know what I am talking about.
----------------------------------------------------------------------------------------------------------------
#negative binomial or poisson?
#import data: asian counts and plot level veg data
Amyn<-read.table('K:/prelim_cn_amyn_1-10.csv', header=TRUE, sep = ",")
#nb or poisson regression? if mean = var then P; if mean < var then nb. Or,
if Poisson, then v/m = ~1
amyn.x <-mean(Amyn$NoAmythas_spp)
amyn.v <-var(Amyn$NoAmythas_spp)
amyn.v/amyn.x
#histogram of amythas counts; use prob=T for density hist
windows()
hist(Amyn[,2])
hist(Amyn[,2], prob=T)
#nb and poisson regression of the models you want to compare (global models
probably)
library(MASS)
amyn.pm1<-glm(Amyn$NoAmythas_spp~OVER_TPH+PERC_HEM+TCperHA,Amyn,
family=poisson)
amyn.pm1sum<-summary(amyn.pm1)
amyn.nbm1<-glm.nb(Amyn$NoAmythas_spp~OVER_TPH+PERC_HEM+TCperHA,Amyn)
amyn.nbm1sum<-summary(amyn.nbm1)
#cdf of data and randomized poisson and nb dist's, see which looks closer to
the data
library(Hmisc)
windows()
nb <-rnbinom(1000000,size=amyn.nbm1sum$theta, mu=amyn.x)
p <-rpois(1000000,lambda=amyn.x)
Ecdf(Amyn$NoAmythas_spp); Ecdf(nb, add=T, col=2); Ecdf(p, add=T, col=3)
#neg bin is red, poisson is green, data is black
-chris
On Tue, Feb 2, 2010 at 6:14 AM, Tore Chr Michaelsen <
tore.michaelsen@...> wrote:
> Thank you for your advice!!!
>
> Zuur et al (2009) is now on its way to my mail box.
>
> Best wishes;
> Tore
>
>
> -----Opprinnelig melding-----
> Fra: Maarten de Groot [mailto:Maarten.deGroot@...]
> Sendt: 2. februar 2010 08:07
> Til: Miltinho Astronauta
> Kopi: Tore Chr Michaelsen; r-sig-ecology@...
> Emne: Re: [R-sig-eco] Low counts
>
> Hi Tore,
>
> How does your count distribution look like? Doe you have more zero's
> than expected (use zero inflated models), no zero's (use zero truncated
> models) or is there no problem with zero's? If it is the latter, it
> might be useful to try the negative binomial models (glm.nb()). Zuur et
> al (2009) gives a nice example that they still find a pattern in the
> residuals with a quasi poison model but no pattern with a negative
> binomial model.
>
> Kind regards,
>
> Maarten
>
> Miltinho Astronauta wrote:
> > Hi Tore,
> >
> > I put my 2cents on Zuur et al 2009's book - Mixed effect models...
> > See Zero-Inflated examples in there.
> >
> > cheers
> >
> > milton
> >
> > 2010/2/1 Tore Chr Michaelsen <tore.michaelsen@...>
> >
> >
> >> Dear members;
> >>
> >> 1) I have fitted a glm to count data (using quasipoisson to correct for
> >> disp.). In the final model, the relationship between Res and Fitted
> (i.e.
> >> the line going through the plot) and QQ looks fine, but I am worried
> that
> >> low count (one to five) could violate some assumption of the
> glm/poisson:
> >> Although the line in the Res vs Fitted plot looks nice, the values show
> a
> >> clear pattern (five diagonal lines = the counts). Crawley/R book says it
> >> should look like the sky at night with no patterns. I assume patterns
> are
> >> not visible with large counts (e.g. 0-100), but highly visible with low
> >> counts as in this case. I still assume this is reason for some concern
> >> about
> >> the model, or is the concern not justified?
> >>
> >> 2) Any recommendations on literature regarding model inspection in R.
> >>
> >> Thank you for reading this mail!
> >>
> >> Best wishes;
> >> Tore
> >>
> >> _______________________________________________
> >> R-sig-ecology mailing list
> >> R-sig-ecology@...
> >> https://stat.ethz.ch/mailman/listinfo/r-sig-ecology
> >>
> >>
> >
> > [[alternative HTML version deleted]]
> >
> > _______________________________________________
> > R-sig-ecology mailing list
> > R-sig-ecology@...
> > https://stat.ethz.ch/mailman/listinfo/r-sig-ecology
> >
> >
>
> _______________________________________________
> R-sig-ecology mailing list
> R-sig-ecology@...
> https://stat.ethz.ch/mailman/listinfo/r-sig-ecology
>
--
--
"I have always suspected that if our economic and political problems are
ever really solved, life will become simpler instead of more complex, and
that the sort of pleasure one gets from finding the first primrose will loom
larger than the sort of pleasure one gets from eating an ice to the tune of
a Wurlitzer." - George Orwell
[[alternative HTML version deleted]]
RSS Feed