1

We got this error because we have some zero's in our dataset. Does it have any effect if we will change them to NA or adding one to all the values that we have. Or has it an effect on our analyis?

fit1 = glm(actspan~treatment+colony, family = Gamma(link = "log"), data = data)

Error in eval(expr, envir, enclos) : non-positive values not allowed for the 'gamma' family

Is this a good solution? Or wil it change our results

fit1 = glm(1+actspan~treatment+colony, family = Gamma(link = "log"), data = data)
Bryan Hanson
  • 6,055
  • 4
  • 41
  • 78
Boris
  • 35
  • 1
  • 4
  • Which programming language/library are we talking about? – Willem Van Onsem Jan 03 '16 at 13:14
  • @willem library lme4 – Boris Jan 03 '16 at 13:52
  • FWIW, `glm` comes from `stats`. Do you have any zeros in your `data`? – Roman Luštrik Jan 03 '16 at 14:00
  • Yess I have, that's the problem. That's why I get the error, So I thought of adding 1 to every value for transformation (but I don't know if it would change my analysis) – Boris Jan 03 '16 at 14:34
  • @Boris You should make it easier for people to work out a solution by including a sample of your data. See [this question](http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) for ways to do this. – nrussell Jan 03 '16 at 14:57
  • voted to close/migrate to [Cross Validated](https://stats.stackexchange.com). This is a slightly deep question: whether you (1) throw away zero values (= set them to NA or drop from the data set); (2) add a little fudge factor; (3) modify your statistical model somehow depends a huge amount on *why* you have zeros in your data ... (e.g. see [this CV question](http://stats.stackexchange.com/questions/16857/a-mixed-model-with-gamma-distribution-handling-zeros) – Ben Bolker Jan 03 '16 at 18:57

0 Answers0