How to transform count response variable including zero values to non-negative values for fitting a GAM analysis? 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 *


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.


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.

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.
