colin - 1 year ago 74

R Question

I am fitting gam's to data on the interval (0,1) using the

`gam`

`mgcv`

`mod <- gam(y ~ x1 + x2 + s(latitude, longitude), faimly=betar(link='logit'), data = data)`

Model fits well, but when I plot the fitted vs. observed values, it looks like this:

`plot(data$y ~ fitted(mod), ylab='observed',xlab='fitted')`

Clearly, the model is fitting values greater than 1 and less than 0. This is not supposed to happen. It violates the assumptions of the beta distribution. It doesn't happen when I model the same data in the

`betareg`

Answer Source

`mod <- gam(y ~ x1 + x2 + s(latitude, longitude), faimly=betar(link='logit'), data = data)`

It appears if you use `faimly`

(typo), `gam`

doesn't complain and goes ahead and does a Gaussian. Try:

`print (mod)`

And see if it says "Family: Beta regression" or "Family: Gaussian"