In fitting GAMs to some data, my interest is in using inverse estimation to find the value of the predictor $X$ that corresponds to a given value of the response $Y$.
I have written some R code to compute $X$ from $Y$ with corresponding large-sample confidence interval.
My issue now is in using simulation of GAMs to find estimates of bias and standard error for the inverse estimates. However, when I apply bootstrapping, sometimes R throws errors that can't seem to be debugged, such as "replacement has length zero".
Is this problem due to the inherent structure of GAM (in mgcv)?
I read this previous post
Can I use bootstrapping to estimate the uncertainty in a maximum value of a GAM?
and it seems similar to what I would like to be able to do (predict the $X$ given $Y$). This approach uses lpmatrix to simulate from the posterior of the GAM covariates. Can the same be done using jagam (though this approach is in itself unstable)?
jagam()
? Also, the specific error sounds like a bug in your wrapper; I've seen & coded several bootstrap-based approaches for the sorts of things you mention and never had a problem (beyond the know issues of bootstrapping GAMs). $\endgroup$jagam()
. The only drawback mentioned is that the general gibbs sampling done by JAGS will not be as efficient as using GAM-specific fully-Bayesian implementations like BayesX. $\endgroup$x
giveny
, you will need some criterion by which to choosex
; I have seen examples where we search for the value ofx
that minimises the log-likelihood of observing the statedy
. Basically, if you have a way to findx
for a giveny
, rewrite it so it uses predictions via the $Xp$ matrix and then all you need to do is replace the usage of coefficients from the fitted model with draws from a multivariate normal with mean vector given by the estimated model coefficients and covariance matrix given by the covariance matrix of the estimated parameters. $\endgroup$