dill / mgcvUtils

Various mgcv-related GAM utilities
Other
10 stars 0 forks source link

Proposal for quantile.gam method #8

Open mfasiolo opened 4 years ago

mfasiolo commented 4 years ago

Maybe it would be useful to add a quantile.gam method that works as in the example below. One can do the same thing by using family$qf, but maybe this is more convenient (especially considering the fact that prior weights and scale are not relevant for many gamlss families). Similarly wrappers could be provided to access family$cdf or other slots more conveniently.

library(gamUtils); library(MASS)
b <- gam(list(accel~s(times,k=20,bs="ad"),~s(times)),
         data=mcycle,family=gaulss())

qfit <- quantile(b, c(0.05, 0.25, 0.5, 0.75, 0.95))

plot(mcycle, ylim = c(-160, 100))
for(ii in 1:ncol(qfit)){
  lines(mcycle$times, qfit[ , ii], col = 2)
}
dill commented 4 years ago

Sorry for the late reply on this! This is very cool! I end up wanting this kind of thing quite often so this will likely save me some time. Thanks for adding this!