1

I am fitting gam's to data on the interval (0,1) using the gam function of the mgcv package in R. My model code looks like this:

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')

enter image description here

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 package for R. What might be causing this discrepancy?

colin
  • 2,606
  • 4
  • 27
  • 57
  • 4
    How are you determining "fitted"? If you're using `predict`, you'll want to use the argument `type="response"`, otherwise it will go outside of the range. If you're using the `fitted` function, I'm not sure. – Wayne Sep 01 '16 at 15:18
  • @Wayne I'm obtaining fitted values using `fitted(mod)`. Plotting is done with `plot(y ~ fitted(mod))` – colin Sep 01 '16 at 15:32

1 Answers1

7

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"

Wayne
  • 933
  • 7
  • 11