[R] Error message when using zero-inflated count regression model in package zicounts

Achim Zeileis Achim.Zeileis at wu-wien.ac.at
Thu Aug 16 17:19:26 CEST 2007


On Thu, 16 Aug 2007, James R. Milks wrote:

> Dr. Stevens,
>
> I've double-checked my variable lengths.  All of my variables
> (Total.vines, Site, Species, and DBH) came in at 549.  I did correct
> one problem in the data entry that had escaped my previous notice:
> somehow the undergrad who entered all the data managed to make the
> Acer negundo data split into two separate categories while still
> appearing to use the same ACNE abbreviation.  When I made that
> correction and re-ran zicounts, R gave me the following error messages:

Hmm, I don't know about the error messages in zicounts, but you could try 
to use the zeroinfl() implementation in package "pscl":
   vines.zip <- zeroinfl(Total.vines ~ Site + Species + DBH | Site +
     Species + DBH, data = sycamores.1)
and see whether this produces a similar error.
Z

> > vines.zip<-zicounts(resp=Total.vines~.,x=~Site+Species+DBH,z=~Site
> +Species+DBH,distname=ZIP,data=sycamores.1)
>
> Error in ifelse(y == 0, 1, y/mu) : dim<-: dims [product 12] do not
> match the length of object [549]
> In addition: Warning messages:
> 1: longer object length is not a multiple of shorter object length
> in: eta + offset
> 2: longer object length is not a multiple of shorter object length
> in: y/mu
>
> In addition, zicounts would not run a normal poisson regression on
> the data, giving me the same error messages as the ZIP regression.
> Doing a poisson regression with glm did not show any error messages.
> However, the glm model with full interactions was still over-dispersed.
>
> Could the zicounts problem be that the individual sites and species
> had different population sizes?  For instance, Site A had 149 trees,
> site B had 55 trees, site C had 270 trees, and site D had 75 trees.
> The species had similar discrepancies in population sizes, with
> Platanus occidentalis and Acer negundo forming the majority of the
> trees.
>
> Thanks for your help.
>
> Jim Milks
>
> Graduate Student
> Environmental Sciences Ph.D. Program
> 136 Biological Sciences
> Wright State University
> 3640 Colonel Glenn Hwy
> Dayton, OH 45435
>
> On Aug 15, 2007, at 5:58 AM, Martin Henry H. Stevens wrote:
>
>> Hi Jim,
>> With regard to same number, I simply wanted to make sure that each
>> variable was the same length. The error message you show is what
>> you would get if, for instance, you misspelled one of the variables
>> and it doesn't exist, in which case it would be NULL, while your
>> other variables would each be 550 elements in length.
>> Hank
>> On Aug 14, 2007, at 4:47 PM, James Milks wrote:
>>
>>> Dr. Stevens,
>>>
>>> Unfortunately, Poisson gives me an over-dispersed model with only
>>> 3 out of 14 variables/interactions significant.  Doing a step-wise
>>> poisson regression still ended up with the same over-dispersed
>>> model.  Given the high number of zeros in the response variable,
>>> Dr. Thad Tarpey (one of our statisticians on campus) suggested
>>> zero-inflated poisson regression as a possible solution to the
>>> over-dispersion problem.
>>>
>>> As for variables of the same length, there are different numbers
>>> of trees for each species and site since we ran different numbers
>>> of transects at each site (some sites were larger than others) and
>>> there were different numbers of species and trees within each
>>> transect.  Acer negundo made up ~33% of all the trees we measured;
>>> Platanus occidentalis had 25%; Fraxinus americana was another 12%
>>> and ~11% was Ulmus americana.  The remaining 25% was divided among
>>> 16 other species, all of which were excluded from the analysis due
>>> to singularities in the model when they were included (something
>>> about glm not liking singularities in the model).  So if the
>>> zicounts requires that each species and site have the same length,
>>> then I will not be able to use it unless I can get R to randomly
>>> select x trees from each species and site combination.
>>>
>>> Thanks for your input.
>>>
>>> Jim Milks
>>>
>>> Graduate Student
>>> Environmental Sciences Ph.D. Program
>>> 136 Biological Sciences
>>> Wright State University
>>> 3640 Colonel Glenn Hwy
>>> Dayton, OH 45435
>>>
>>>
>>> On Aug 14, 2007, at 9:37 AM, Hank Stevens wrote:
>>>
>>>> Hi Jim,
>>>> Two thoughts come to me, unencumbered by the thought process or
>>>> knowledge of zicounts:
>>>> 1. Is Poisson really NOT appropriate? (do you have to use zicounts?)
>>>> 2. Are you 110% certain that all variables are the same length?
>>>> Would NA's interfere?
>>>> Cheers,
>>>> Hank
>>>> On Aug 13, 2007, at 5:10 PM, James Milks wrote:
>>>>
>>>>> I have data on number of vines per tree for ~550 trees.  Over
>>>>> half of
>>>>> the trees did not have any vines and the data is fairly skewed
>>>>> (median = 0, mean = 1.158, 3rd qu. = 1.000).  I am attempting to
>>>>> investigate whether plot location (four sites), species (I'm using
>>>>> only the four most common species), or tree dbh has a significant
>>>>> influence on the number of vines per tree.  When I attempted to use
>>>>> the zicounts function, R gave me the following error message:
>>>>>
>>>>>> vines.zip<-zicounts(resp=Total.vines~.,x=~Site+Species+DBH,z=~Site
>>>>> +Species+DBH,distrname="ZIP",data=sycamores.1)
>>>>> Error in ifelse(y == 0, 1, y/mu) : dim<- : dims [product 12] do not
>>>>> match the length of object [549]
>>>>> In addition: Warning messages:
>>>>> 1: longer object length
>>>>>         is not a multiple of shorter object length in: x[good, ]
>>>>> * w
>>>>> 2: longer object length
>>>>>         is not a multiple of shorter object length in: eta + offset
>>>>> 3: longer object length
>>>>>         is not a multiple of shorter object length in: y/mu
>>>>>
>>>>> I do not know enough about the calculations done in the function to
>>>>> interpret the error messages.  Is there a glitch in my data and if
>>>>> yes, what is it?
>>>>>
>>>>> Thanks for your help.
>>>>>
>>>>> Jim Milks
>>>>>
>>>>> Graduate Student
>>>>> Environmental Sciences Ph.D. Program
>>>>> 136 Biological Sciences
>>>>> Wright State University
>>>>> 3640 Colonel Glenn Hwy
>>>>> Dayton, OH 45435
>>>>>
>>>>>
>>>>>
>>>>>         [[alternative HTML version deleted]]
>>>>>
>>>>> ______________________________________________
>>>>> R-help at stat.math.ethz.ch mailing list
>>>>> 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.
>>>>
>>>>
>>>>
>>>> Dr. Hank Stevens, Associate Professor
>>>> 338 Pearson Hall
>>>> Botany Department
>>>> Miami University
>>>> Oxford, OH 45056
>>>>
>>>> Office: (513) 529-4206
>>>> Lab: (513) 529-4262
>>>> FAX: (513) 529-4243
>>>> http://www.cas.muohio.edu/~stevenmh/
>>>> http://www.muohio.edu/ecology/
>>>> http://www.muohio.edu/botany/
>>>>
>>>> "E Pluribus Unum"
>>>>
>>>>
>>>>
>>>>
>>>>
>>>
>>
>> Dr. Hank Stevens, Associate Professor
>> 338 Pearson Hall
>> Botany Department
>> Miami University
>> Oxford, OH 45056
>>
>> Office: (513) 529-4206
>> Lab: (513) 529-4262
>> FAX: (513) 529-4243
>> http://www.cas.muohio.edu/~stevenmh/
>> http://www.muohio.edu/ecology/
>> http://www.muohio.edu/botany/
>> "E Pluribus Unum"
>>
>> If you send an attachment, please try to send it in a format anyone
>> can read, such as PDF, text, Open Document Format, HTML, or RTF.
>> Please try not to send me MS Word or PowerPoint attachments-
>> Why? See:  http://www.gnu.org/philosophy/no-word-attachments.html
>>
>>
>>
>>
>
>
> 	[[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> 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.
>
>



More information about the R-help mailing list