--
You received this message because you are subscribed to the Google Groups "R-inla discussion group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to r-inla-discussion...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/r-inla-discussion-group/3dcb7f25-a986-46dc-b1f7-381b0596df71n%40googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/r-inla-discussion-group/248dcfda-31b0-46d7-ba66-6834e7fa727en%40googlegroups.com.
Hi Finn and Boris,
Finn......I can understand that our choice to use mgcv smoothers in INLA may look weird...but what you are missing is the general picture behind it.
The ecological data sets that we use in the book are more complicated
than the classical textbook examples. The data sets that we use contain
multiple collinear covariates (which all have non-linear effects +
interactions) and with plenty of zeros in the response variable and also
spatial (-temporal) dependency. I call those 'shitty data sets'.
Using either INLA or mgcv, it is easy to end up with a model in which the smoother(s), spatial correlation and the zero-inflation component of the statistical distribution all fight for the same information (e.g. zeros at sites close to each other, with similar covariate conditions). In such a situation, you quite often end up with a smoother that contains all kinds of bumps that do not make any ecological sense. One strategy to deal with this problem is to force the smoother to be more simple (in mgcv language..stick to smoothers with not more than 4 or 6 df). If you are lucky, you then up with patterns that do make ecological sense (e.g. plateau type relationships). But obviously, sometimes you need more variation in the smoothers.
So.....our approach in the book is to borrow the function `smoothCon`
from mgcv, obtain the basis functions of a simple smoother (e.g. an
unpenalised cubic regression spline) at a limited number of knots, and
write the smoother as X * beta. It then becomes a linear regression or a
GLM. The main idea is to extract a signal that is simple and easy to
comprehend.
I do agree that the coding becomes slightly cumbersome....but at the
end of the day, it forces you to know what you are doing. And yes, there
are pitfalls (like knot positions and the number of knots).
I also agree that if rw1/rw2 gives you a decent working model in INLA, then
that is considerably more convenient than going for unpenalised
smoothers borrowed from mgcv. But for the shitty data sets that we use in the
book, rw1/rw2 turned out to be a (too) big battle with priors. From an
ecological point of view, it is much easier to force the smoothers to be
simple and easy to understand.
Boris..as to your specific question....here is some example code. I want a smoothing function of depth. The first block of code uses smoothCon from mgcv to obtain the basis functions.
# Extract the X matrices
XDepth <- Lego.Depth$X #X for the Depth smoother
The XDepth contains the basis functions. It is just a set of artificial covariates that forms the backbone of the smoother. You let INLA (or lm, or glm, lmer or glmmTMB) estimate the corresponding regression parameters. One option to plot the smoother in INLA is inla.make.lincombs.
If you want to do what you asked in your original post, then you have
to follow the same steps that the predict function from mgcv is doing.
First, you have to make up the values of Depth for which you want to
predict.
MyDataPred <- data.frame(
Depth = seq(from = min(EU2$Depth),
to = max(EU2$Depth),
length = 100),
SweptArea = mean(EU2$SweptArea))
Obviously, you can add more covariates. You now need to get the basis
functions for these specific depth values. We can borrow again tools from mgcv:
# Basis function for the 100 artificial depth values.
XpDepth <- PredictMat(Lego.Depth, MyDataPred)
This XpDepth can go into the second stack (with NA for the response
variable)....and you rerun the model (after combining the two stacks).
If you get stuck, feel free to drop me an email.
To come back to Finn's comments...it all comes down to how you want
to use a smoother. Do you allow it to do whatever it wants, or do want
to force it to be something simple? And if you opt for the latter
approach, how do you want to do that? Do you do it via priors on rw1/rw2
terms in INLA, increasing the penalty for non-smoothness in mgcv,
limiting the number of knots in mgcv/INLA, or specifying the amount of smoothing
a priori in mgcv? I essentially adopted the old S-PLUS approach and use
mgcv smoothers with 4 or 5 df. And if my residuals show a pattern I
will consider increasing it.
Feel free to disagree with this approach...but I call it pragmatic for shitty data sets.
Kind regards,
Alain
--
You received this message because you are subscribed to the Google Groups "R-inla discussion group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to r-inla-discussion...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/r-inla-discussion-group/867123e0-782c-4a86-9615-16cbd255c659n%40googlegroups.com.