Thank you for your answer! I am wondering wether I can solve this problem by two steps:
1. To get posteriori distribution of cosmological parameters:
sampling from marginal posterior of hyperparameters with a transformation function. Where the transformation function is the regression function
cosmic.Para = beta_0 + beta_1*HP1 + … + eps
cosm.Para.samp <- inla.posterior.sample.eval(function(...) {Regressionformula},
m1.samp)
2. Include the cosmological parameters in the prior:
For example, very simplified:
prec.prior <- list(prec = list(prior = "loggamma", param = c(cosm.para1, cosm.para2)),
initial = 4, fixed = FALSE)
f <- y ~ 1 + f(idx, model = "iid", hyper = prec.prior)
cosm.para1 and cosm.para2 are sampled from their prior distribution beforehand.
Is the implementation in inlabru the same?
Even if this approach would make sense I suppose that I couldn´t use all of the R-inla features for analysis?
Regards,
Amelie Liese
Hello Finn,
I would like to get back to my question from August. My question wasn’t clear enough.
I am fitting an SPDE model with r-inla (not inlabru) where the range hyperparameter of the latent field should be conditioned on a cosmological parameter (Omega_M) wich has a flat prior.
range | Omega_M ~ gamma(a*Omega_M, b*Omega_M)
With a, b being some factor.
I guess the code examples of your answer are not intended for a generic SPDE model ?
I think I have to use inla.spde2.generic() function. However I could only find some little information about it and don’t know how to use it correctly.
Thanks and regards,
Amelie Liese
Beyond code chunk may help to understand my problem:
range.prior <- list(range = list(prior = „loggamma“, param = c(a*Omega_M, b*Omega_M)), initial = 4, fixed = FALSE)
# Where I use the ML-Estimate for the range and sigma parameter as priors to generate the spde object
spde <- inla.spde2.pcmatern(mesh, alpha = 2, prior.sigma = c(sigma0_ML,0.5),prior.range = c(range0_ML,0.5))
s.index <- inla.spde.make.index(name = "spatial.field", n.spde = spde$n.spde)
s.stack <- inla.stack(data = list(y=obs), A = list(A),
effects = list(c(s.index, list(Intercept = 1))), tag = "s.data")
s.stack.pred <- inla.stack(data = list(y=NA), A = list(1),
effects = list(c(s.index, list(Intercept = 1))), tag = "s.pred")
join.stack <- inla.stack(s.stack, s.stack.pred)
formula = y ~ -1 + Intercept + f(spatial.field, model = spde, hyper = range.prior)
res_inla <- inla(formula, data = inla.stack.data(join.stack, spde = spde), family = "lognormal",
control.predictor=list(A=inla.stack.A(join.stack), compute =TRUE),
control.compute = list(cpo = TRUE, dic = TRUE, waic = TRUE, config = TRUE),
control.inla = list(int.strategy = "grid"))