Hi all,
I am a new user for nimble, so I don't understand any system well.
In my model, I calculate likelihood from my own equation that contain estimated value from MCMC. For example, in the model below, calculated likelihood is "Likelihoods", and estimated values from MCMC are "mu" and "std".
Can I use this likelihood for Metropolis-Hastings(synonymous with mcmc) ?
It is very difficult to communicate in writing and may not be well explained.
Please ask me any questions if my explanation doesn't make sense.
Thank you for your attention, and any help would be much appreciated!
Oyama
This model below is a very simple example to calculate like-likelihood value.
#### Example Model ####
likeliCode <- nimbleCode({
# prior
mu ~ dexp(1.0)
std ~ dgamma(0.1,1.0)
for (i in 1:N){
likelihood[i] <- x[i] - dnorm(mu,std)
}
Likelihoods <-sum(likelihood[1:N])
})
num = 10
Consts <- list(N = num)
Data <- list(x = c(5, 1, 5, 14, 3, 19, 1, 1, 4, 22))
Inits <- list(mu= 1,
std = 1)
likeli <- nimbleModel(code = likeliCode, name = "likeli", constants = Consts,
data = Data, inits = Inits)
likeConf <- configureMCMC(likeli, print = TRUE)
likeConf$addMonitors(c("Likelihoods", "mu", "std"))
likeMCMC <- buildMCMC(likeConf)
clikeli <- compileNimble(likeli)
ClikeMCMC <- compileNimble(likeMCMC, project = clikeli, resetFunctions = TRUE)
#only compiled project is available??
niter <- 1000
set.seed(1)
samples <- runMCMC(ClikeMCMC, niter = niter)