1
$\begingroup$

I am trying to fit a GAM model that the response variable is count var (species richness) and the predictor variable is elevation. In my dataset there are some zero values for richness in some elevation. This is my model:

mod2 <- gam(Richness ~ s(Elevation, bs="cr"), family=poisson(), data=Palvar.env, method = "REML", scale= 1)

This is the result of gam.check:

 k'  edf k-index p-value  
s(Elevation) 9.00 8.75    0.78   0.015 *

gam.check plots

and the residuals plots are not bad, but not satisfying! The graph resulting of "plot(mod2)"is different from the ggplot graph after doing "predict" function. plot(mod2) ggplot

My question would be, can this problem as a result of zero values of response variable? I tried to transform the richness with log and sqrt, but the error is:


negative values not allowed for the 'Poisson' family or

Error in if (abs(old.score - score) > score.scale * conv.tol) { : 
  missing value where TRUE/FALSE needed
In addition: There were 50 or more warnings (use warnings() to see the first 50) 

I really appreciate it if anyone could help me for solving this problem.

$\endgroup$
2
  • $\begingroup$ Greetings! Can you show the plots you mentioned so it is easier for people to answer the question? $\endgroup$ Feb 21 at 13:01
  • $\begingroup$ The error message may make more sense to people familiar with software, but -- apart from transformation not being a good idea here, as explained in answers -- log of zero is not defined in any case. $\endgroup$
    – Nick Cox
    Feb 22 at 11:55

1 Answer 1

2
$\begingroup$

The Poisson distribution isn't a very flexible distribution because it is defined by a simple location parameter $\lambda$, the expected rate (or count). The variance of a Poisson is also $\lambda$. Many types of data that otherwise look like a count (species abundances, richness) can exhibit more variance than implied by a Poisson distribution with a given $\lambda$.

It's really hard to tell from your diagnostic plots (render to a physically larger device) but it looks like your data have more variance than expected from an assumption that the data are conditionally distributed Poisson with expected (mean) count $\exp(\mu_i)$, where $\mu_i$ is the fitted value of the model for the $i$th observation on the scale of the linear predictor.

If your data are integers, try a negative binomial distribution next as that allows for more variance of the observations than that assumed by the Poisson.

There is no point log-transforming data like this that you feed into a GLM (GAM), as the point of the model is to try to keep the data on its natural scale, do the fitting (for the expected value) on an unbounded scale and then use a link function (and its inverse) to map values to and from the bounded response scale and the unbounded linear predictor scale.

$\endgroup$
1
  • $\begingroup$ Many thanks for your comments and answers. I had previously tried the model with negative binomial family, but it did not show up noticeable difference in my results and plots. I did GAM models adding or changing arguments and then compare them with "anova", but mostly their results or plots are almost similar. I think there is a problem, but I am not sure. Does anybody have other idea or solution? $\endgroup$
    – Atefeh
    Mar 6 at 9:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.