Closed bachlaw closed 2 years ago
Hi, what would you like to simulate? Recall that you cannot simulate the response y, because qgam is model-free and there is no assumption on the distribution of y (so nothing to simulate from). But you could simulate from the posterior of the estimated quantile.
Good point, yes, by definition I would be looking to simulate the posterior distribution of quantile(s) that were modeled.
Incidentally, I tried running gam
and even bam
with the elf
family as indicated in the examples and the results, at least by information criteria, were notably less accurate. Is this why using them instead of the qgam
function, according to the commented text, is "not recommended"? Thanks again.
Ok if you want to simulate quantiles then the approach to use should be the same as for models fitted with gam
. That is you simulate from the posterior the regression coefficients using br <- rmvn(1000,coef(fit),vcov(fit))
. Then you multiply the model matrix X (extracted using predict.gam
with argument type = "lpmatrix"
) by each simulated vector of coefficients and that should give you 1000 simulated quantile fits. Does this make sense?
Fitting QGAMs with gam
or bam
is sub-optimal because these models require an extra calibration step, which is carried out by the qgam
function. The calibration takes some time, but leads to better estimates especially in the tails, see here.
It does make sense! Thanks very much.
I do not see any current method for simulating from a
qgam
posterior distribution. In the meantime, any recommendations for approximating such sampling? Perhaps after some exploratory work inqgam
, try to run the model throughgam
directly? Thanks for the wonderful package.