library(nimble)
pumpCode <- nimbleCode({
for (i in 1:N){
theta[i] ~ dgamma(alpha, beta)
lambda[i] <- theta[i] * t[i]
x[i] ~ dpois(lambda[i])
}
alpha ~ dexp(1.0)
beta ~ dgamma(0.1, 1.0)
})
pumpConsts <- list(N = 10, t = c(94.3, 15.7, 62.9, 126, 5.24, 31.4, 1.05, 1.05, 2.1, 10.5))
pumpData <- list(x = c(5, 1, 5, 14, 3, 19, 1, 1, 4, 22))
pumpInits <- list(alpha = 0.1, beta = 0.1, theta = rep(0.1, pumpConsts$N))
pump <- nimbleModel(code = pumpCode, name = "pump", constants = pumpConsts,
data = pumpData, inits = pumpInits, buildDerivs = TRUE)
Cpump<- compileNimble(pump)
Confpump<-configureMCMC(pump, thin =10, monitors =
c("alpha","beta"))
# Build Laplace approximation
pumpLaplace <- buildLaplace(pump)
Confpump$removeSamplers(c("alpha","beta"))
Confpump$addSampler(target = "alpha", type = "RW_llFunction",
control = list(llFunction = pumpLaplace, includesTarget = FALSE))
Confpump$addSampler(target = "beta", type = "RW_llFunction",
control = list(llFunction = pumpLaplace, includesTarget = FALSE))
ModelMCMCpump <- nimble::buildMCMC(Confpump)
CModelMCMCpump <- nimble::compileNimble(ModelMCMCpump, project =Cpump)
The error message is:
Error: In sizeAssignAfterRecursing: LHS is not in typeEnv or symTab and cannot be added now.
This occurred for: modelLP0 <- nfMethod(cppPointerDereference(llFunction),"run")()
This was part of the call: {
modelLP0 <- nfMethod(cppPointerDereference(llFunction),"run")()
if(!(includesTarget)) {
modelLP0 <- modelLP0 + getLogProb(nodeFxnVector=model_target_nodeFxnVector_includeData_TRUE_SU_)
}
propValue <- rnorm(n=1,mean=model_oB_oBtarget_cB_cB[model_oB_oBtarget_cB_cB_flatIndex],sd=scale)
nfMethod(my_setAndCalculateOne,"run")(propValue)
modelLP1 <- nfMethod(llFunction,"run")()
if(!(includesTarget)) {
modelLP1 <- modelLP1 + getLogProb(nodeFxnVector=model_target_nodeFxnVector_includeData_TRUE_SU_)
}
jump <- nfMethod(my_decideAndJump,"run")(modelLP1, modelLP0, 0, 0)
if(adaptive) {
nfMethod(targetRWSamplerFunction,"adaptiveProcedure")(jump)
scale <<- nfVar(targetRWSamplerFunction,"scale")
}
}
Do you see where my code went wrong? Is there an issue within the package?
I thank you very much in advance,
Frédéric
--
You received this message because you are subscribed to the Google Groups "nimble-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to nimble-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/nimble-users/fae0f1be-3389-42e3-8036-772da8d1cc46n%40googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/nimble-users/aea26fb3-9692-4dc9-bbe3-b9823d0aa694n%40googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/nimble-users/CAKbe0hqiAmrsqLWtqbRf_zkYjqqY39CJX7EEsOS%3DN2s2RjcOAA%40mail.gmail.com.