First, everything in R is treated like as an object. We have seen this with functions. Many of the objects that are created within an R session have attributes associated with them. One common attribute associated with an object is its class.
Model improvement follows the idealized steps listed on the first page of Bayesian Data Analysis:
Set up a full probability model. Define a joint probability distribution for all observable and unobservable quantities in a problem. The model should be consistent with knowledge about the underlying scientific problem and the data collection process.
Condition on observed data. Calculate and interpret the appropriate posterior distribution – the conditional probability distribution of the unobserved quantities of ultimate interest, given the observed data.
Evaluate the fit of the model and the implications of the resulting posterior distribution. How well does the model fit the data, are the substantive conclusions reasonable, and how sensitive are the results to the modeling assumptions? In response, one can alter or expand the model and repeat.
Be sure that your Stan programs ends in a blank line without any characters including spaces and comments.
In this Stan program, we let theta be a transformation of mu, eta, and tau instead of declaring theta in the parameters block, which allows the sampler will run more efficiently (see detailed explanation). We can prepare the data (which typically is a named list) in R with: