I have been playing around with the implementation of af terms on the pfr-devel branch. af has an option Qtransform, which does a time-specific quantile transformation of the X function, which is really useful. One thing I didn't like about this is that when you plot/extract the coefficient, it is still on the transformed scale. This makes it hard to interpret the coefficient on the original scale, especially because the quantile transformation is time-specific.
The "dt" basis that I wrote solves this problem, so I changed the Qtransform implementation to use this basis. The model fits exactly the same (same exact spline coefficients!), the difference is it makes the quantile transformation transparent so plotting/extracting the coefficient can be done on the original scale.
I would, however, like to make extracting/plotting on the transformed scale available. This ended up being a little trickier than I was hoping. I've been considering two strategies for this:
- In
plot.pfr, inject code (using trace) into plot.mgcv.smooth, which changes the coordinates to their transformed versions. This has to be done in plot.mgcv.smooth instead of plot.gam, because the grid isn't generated until plot.mgcv.smooth. The problem is that I don't know how to trace into an unexpected function without using :::, which we need to avoid.
- Do everything manually for these terms. This would be annoying.
Any ideas?
I have been playing around with the implementation of af terms on the pfr-devel branch.
afhas an optionQtransform, which does a time-specific quantile transformation of the X function, which is really useful. One thing I didn't like about this is that when you plot/extract the coefficient, it is still on the transformed scale. This makes it hard to interpret the coefficient on the original scale, especially because the quantile transformation is time-specific.The
"dt"basis that I wrote solves this problem, so I changed theQtransformimplementation to use this basis. The model fits exactly the same (same exact spline coefficients!), the difference is it makes the quantile transformation transparent so plotting/extracting the coefficient can be done on the original scale.I would, however, like to make extracting/plotting on the transformed scale available. This ended up being a little trickier than I was hoping. I've been considering two strategies for this:
plot.pfr, inject code (usingtrace) intoplot.mgcv.smooth, which changes the coordinates to their transformed versions. This has to be done inplot.mgcv.smoothinstead ofplot.gam, because the grid isn't generated untilplot.mgcv.smooth. The problem is that I don't know how to trace into an unexpected function without using:::, which we need to avoid.Any ideas?