aknandi / disaggregation

R package containing methods for Bayesian disaggregation modelling
Other
21 stars 6 forks source link

Remove last inla function #80

Closed timcdlucas closed 2 weeks ago

timcdlucas commented 11 months ago

inla.spde2.matern()

simon-smart88 commented 3 months ago

@timcdlucas

I'm fairly sure this can't be done with {fmesher} but I can get the first two matrices with this:

rspde <- rSPDE::matern.operators(mesh = data$mesh, alpha = 2)$fem_mesh_matrices

You might be able to look at the docs and make sense of how we get the third? https://cran.r-project.org/web/packages/rSPDE/rSPDE.pdf

Current usage is here: https://github.com/aknandi/disaggregation/blob/cd7e7ef9a9f1714bba199e55e604bbfb64080959/R/fit_model.R#L359

simon-smart88 commented 3 months ago

compute_higher_order = TRUE is what we need

simon-smart88 commented 3 months ago

Full example. identical doesn't give TRUE for M1 and M2 but I'm not sure why as the values are identical.

spde <- (INLA::inla.spde2.matern(data$mesh, alpha = 2)$param.inla)[c("M0", "M1", "M2")]
rspde <- rSPDE::matern.operators(mesh = data$mesh, alpha = 2, compute_higher_order = TRUE)$fem_mesh_matrices

rspde[[4]] <- NULL
names(rspde) <- c("M0", "M1", "M2")

identical(spde[[1]], rspde[[1]])
identical(spde[[2]], rspde[[2]])
identical(spde[[3]], rspde[[3]])

sum(spde[[2]] - rspde[[2]])
sum(spde[[3]] - rspde[[3]])
simon-smart88 commented 3 months ago

@timcdlucas I think we can remove skip_on_cran() once this is done, but thought best to check.

timcdlucas commented 3 months ago

Yup we should be able to. There's CI routines (can't remember the word) that test as if it's on CRAN I think. So we should be able to check that everything works fine as well.

simon-smart88 commented 2 weeks ago

@timcdlucas Can you close this?