A hard modeling problem using Bayesian inference

You need to actually read the error messages. The error message says yT is not found and that’s what’s going on. Start from the assumption that the error message is right and figure out why you’re getting it. We don’t have a lot of time to debug user programs step by step.

2 Likes

I understand the meaning of that error. What I don’t understand is why it requires me to specific yT in the R code? I thought we already defined it in Stan, and now we have to define it again?? How could we declare yT as a variable in this case though, as I could not see how to do this?

Also, when I switched from yT = yT to yH = yH in the datalist(yH=yH,ncol = ncol, nrow=nrow, A=A ) function and ran the code, it was able to execute successfully. However, when I added the two following lines of code (thanks to your link!!), I got the meaningless result: Stan model ‘56827d6b7a762380b4e29186578344f8’ does not contain samples. NULL.

class(fit)
print(names(summary(fit)))

This means the sampling function that I used: fit <- sampling(ret_sm, warmup=100, iter=600, seed=1, data=list(yH = yH, ncol = ncol, nrow=nrow, A=A), did not run at all?! Could you please help me fix this error? Why the number of iterations was set to 600 but the sampling() function did not run??

I read it, but what could I do if I tried fixing it, and it never works but just gives me the same error? I thought you would be able to help me with the execution code, Dr. Carpenter;( Sorry for asking you trivial (to you, but not to me) questions…

Hi,

I assume that you have misunderstood how Stan/RStan works. It is not your normal R module (I come from the python side so the module might not be the correct name here) where you call its functions as any other modules (ggplot2 etc) in R. You should consider Stan as an external program that you send the data through RStan interface and get results back in a container. From this container you can extract your samples and then process them with normal R functions.

So the namespace and the variables defined in Stan are independent of your variables in the R namespace.

I recommend that you familiarize the concepts and the common way of defining models with the Stan manual. Start with something simple and work your way to the more complex models.

4 Likes