inlabru-org / inlabru

inlabru
https://inlabru-org.github.io/inlabru/
76 stars 21 forks source link

spatial covariate model types #56

Closed stanbiryukov closed 5 years ago

stanbiryukov commented 5 years ago

Hi there - is there support for including spatial covariates other than the linear model? For example, I'm unclear what the 'n' component should be in this example, where cov is of class SpatialPixelsDataFrame: rdmdl <- y_max ~ -1 + beta.rd(map = cov, model = "clinear", range = (0, 2))

fbachl commented 5 years ago

Hi Stan,

in principle the aim of inlabru is that you can use any of the latent models INLA provides. Here's an example of using a 1D SPDE for a non-linear effect of the elevation covariate in the Gorilla data set:

data(gorillas, package = "inlabru")
elevation <- seq(min(gorillas$gcov$elevation$elevation),
                 max(gorillas$gcov$elevation$elevation),
                 length = 100)
mesh1D <- inla.mesh.1d(elevation)
cmp <- coordinates ~ beta.elev(map = gorillas$gcov$elevation, model = inla.spde2.matern(mesh1D)) + Intercept
fit <- lgcp(cmp, gorillas$nests, samplers = gorillas$boundary) 
plot(x=elevation, y=fit$summary.random$beta.elev$mean, type="l")

There are two issues, though: 1) We are developing a new backend for inlabru that will support more (all?) of the latent models INLA offers. You can try it out using the "backend-clean" branch in Git. Our version is a bit behind, though, and some model's don't work 2) When you are using a SpatialXXXDataFrame as covariate it is quite easy to make spatial predictions. However, there is no elegant syntax yet on how to predict/plot the non-linear effect I used above. You have to manually inspect the obejct that comes out of lgcp()/bru().

Hope this helps, Fabian

stanbiryukov commented 5 years ago

Hi Fabian, Thanks for the helpful example - didn't think of incorporating the 1D mesh approach. I'll try out the backend-clean branch. Best, Stan