gavinsimpson / gratia

ggplot-based graphics and useful functions for GAMs fitted using the mgcv package
https://gavinsimpson.github.io/gratia/
Other
206 stars 28 forks source link

fitted_values does not currently work with betar family #234

Closed sambweber closed 1 year ago

sambweber commented 1 year ago

I'm currently getting errors when applying the fitted_values function to a model fit using betar() family. It works with all other error families. I'm using gratia 0.8.1. See reprex below:

# Simulate some beta distributed data using gamSim
dat <- gamSim(1,n=100)
mu <- binomial()$linkinv(dat$f/4-2)
phi <- .5
a <- mu*phi;b <- phi - a;
dat$y <- rbeta(100,a,b) 

# Fit model and attempt to extract fitted values
bm <- gam(y~s(x0),family=betar(link="logit"),data=dat)
fitted_values(bm)
gavinsimpson commented 1 year ago

Thanks @sambweber This was fixed in 1ee4d15. If you install the development version (0.8.1.35 currently) with instructions here it hopefully works for your real model - the reprex works for me.