简体   繁体   中英

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

在此处输入图片说明

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?

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"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM