Hi Nimble team
I do have a process-based model with 5 parameters that is computationally expensive to run. So over a gird of these 5 parameters, I developed a GP model to estimate the log-likelihood given a set of observations. Now given a GP model that simulates the log-likelihood I'd like to optimize these 5 parameters.
My nimble model looks like this :
```
code <- nimbleCode({
p1 ~ T(dnorm(0.047, 0.5), 0.035, 0.055)
p2 ~ T(dnorm(-1.17, 1), -1.25, -1.05)
p3 ~ dunif(200, 500)
p4 ~ T(dnorm(23, 15), 15, 30)
p5 ~ T(dnorm(50, 30), 30, 80)
sigma ~ dunif(0, 5)
sigma2 ~ dunif(0, 5)
ssq <- predic_NIMBLE_func(1, p1, p2, p3, p4 , p5)
ssq2 <- predic_NIMBLE_func(2, p1, p2, p3, p4 , p5)
})
```
In the above code `predic_NIMBLE_func` is `nimbleRcall` which returns the log-likelihood. I have tested the `predic_NIMBLE_func` and it works properly.
Here is also my `nimbleFunction` for the llFunction in `RW_llFunction_block` sampler.
```
llFun <- nimbleFunction(
setup = function(model) { },
run = function() {
p1 <- model$p1
p2 <- model$p2
p3 <- model$p3
p4 <- model$p4
p5 <- model$p5
ssq <- model$ssq
ssq2 <- model$ssq2
sigma <- model$sigma
sigma2 <- model$sigma2
ll <- # estimate the likelihood
returnType(double())
return(ll)
}
)
RllFun <- llFun(Rmodel)
RllFun$run()
mcmcConf <- configureMCMC(Rmodel, nodes = NULL)
mcmcConf$addSampler(target = c("p1", "p2", "p3", "p4", "p5",
"sigma","sigma2","cc"),
type = "RW_llFunction_block",
control = list(llFunction = RllFun,
adaptInterval=20,
adaptive=TRUE,
includesTarget = FALSE))
```
So my problem is that, it looks like the MCMC doesn't use the defined `llFun` function mainly because the posteriors are exactly the same as priors. I get the same posterior even when I set the `ll` to a constant in `llFun` function.
It appears that I have an issue in the way I have defined my model. I was wondering if you could let me know if you see a major problem in my model.