Search code examples
rbeta-distributiongammgcv

Beta family in gam model fitting values greater than 1 and less than 0. Whats going on? (mgcv)


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?


Solution

  • 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"