I have gone through your posted code and have a couple of comments/ideas here:
- The boundary object that you're supplying does not have the variable
f
in each boundary list. This variable tells the model what to do right at the boundary. You will want to setf
to0
considering you want to model occurrence in the lake. Please the vignette/blog post on when in the code and how to createf
. - I have created the following GitHub repo with my edits to the code. I still cannot get {gratia} to draw the model, as it produces the same error, but you should be able to predict densities across the lake by following the blog/the GitHub repo uses the same methodology
- To check fixed and random effects and smoothers. I suggest looking at the main effects of the model first prior to running
summary()
. This can be done usinganova.gam()
oranova()
. You will notice for the soap-film model thatorigin
is not statistically significant which for the thin-plate model it is. - I did not change this in my code but I do agree with @robert-lennox that your
k
value is likely to high resulting in the model overfitting. study_year
is currently as smoother, do you want this or do you want this as a random effect. This could be why gratia is having a hard time with drawing it as you'll notice at the end of my script I usefacet_grid()
to plotorigin
andstudy_year
.- List item