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.