Struggling to fit covariates with LGCP #199
-
Hi, I'm trying to include a habitat covariate within my LGCP, but running into issues. Is there a problem with the code below? Specify hazard-rate detection functionhn <- function(distance, lsig) {1 - exp(-(distance / (exp(lsig)))^-1)} Define a (Matern) covariance function for the SPDEmatern <- inla.spde2.pcmatern(mesh, Specify components of modelcmp2 <- coordinates ~ Specify formulaform <- coordinates + distance ~ mySPDE + log(hn(distance, lsig)) + Intercept + log(2) fit2 <- lgcp( The error message I get when running this is: |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 6 replies
-
Hi, Your components definition appears to be missing the lsig(1) and Intercept(1) parameters, not certain if this will fix the error but worth fixing to see. Andrew |
Beta Was this translation helpful? Give feedback.
-
I suspect an issue with the covariate, but need more info; the |
Beta Was this translation helpful? Give feedback.
Thanks! Does it run without the covariate component? The error trace seems to indicate it's having trouble identifying the possible values of the covariate. The main issue I think is that there is no
eval_spatial.RasterLayer
, so inlabru doesn't realise it would have needed to do spatial evaluaton of the covariate. Fortunately, theterra
style of rasters are supported, so I think you can solve the issue by simply converting it before running the model. I'm guessing that yourCovariates
object is a full raster object, in which case you can probably do this:Otherwise you'd need to convert the individual layer.
I don't think you need to change anything …