error: invalid data: family = 3, x = 0.000000, xpred = 1.000000

231 views
Skip to first unread message

JSG

unread,
May 22, 2014, 11:36:34 AM5/22/14
to aster-analys...@googlegroups.com
[copied from email...]

I ran your test code and got the error message:

    > out1<-aster(resp~varb+level:(Xcoord+Ycoord), pred, fam, varb, id, root, data=retest) # doesn't work... 
    Error in mloglhelper(parm, pred, fam, x, root, modmat, origin, deriv = 0, : invalid data: family = 3, x = 0.000000, xpred = 1.000000

Though it's hard to know the first time you see it, this is an informative error message! It tells you that the input data from one of your predecessors to a variable with "family = 3" is not appropriate. 


    > fam.default() 
    [[1]] [1] "bernoulli" 
    [[2]] [1] "poisson" 
    [[3]] [1] "truncated.poisson(truncation = 0)" 
    [[4]] [1] "truncated.poisson(truncation = 2)"


From "fam.default()" I see that family=3 is a truncated.poisson(truncation = 0) which means that all the values for this level of varb should be integers greater than zero. Doing a quick check

    > trunc.pois.vars <- vars [fam==3]
    > trunc.pois.vars 
    [1] "FL12" "FL13" "FR12" "FR13"
    >
    > nrow(retest[which(retest$varb %in% trunc.pois.vars & retest$resp == 0), ])
    [1] 494

I see that you have 494 rows where resp == 0, when (given the trunctated family you've assigned), aster expects a value of 1 or greater.

So, you should go back and check your raw data to make sure it's consistent with your life history model. Anything that has a "1" preceding a "FL" or "FR" variable should have a positive integer for that variable. 

Possible solutions:

1) Use a regular poisson distribution instead of the truncated. A potential problem with this (not having looked at your data) from my experience is that there is often a large mode at zero (one of the very reasons we use aster models) which makes it difficult for the algorithm to converge on a parameter estimate for the level of varb. 

2) Add a new binomial variable between the AG/RS levels and the FL/FR levels. This variable would be a bernoulli "any fruits" or "any flowers" variable. That is, given that "AG" or "RS" == 1 (whatever those stages are), did a plant produce any flowers/fruits? If so (>=1), then you can use the truncated.poisson for the next level. This is the strategy I used in my own analyses. See the "README.R" file associated with the "Fitness data for experimental populations" data set here: http://datadryad.org/resource/doi:10.5061/dryad.d2c619hd. On line 99 I define a variable "anypods" that I then use in my aster analysis.

best of luck,
John
Reply all
Reply to author
Forward
0 new messages