From the Bayes’ Analysis 4, we saw such a diagram:

knitr::include_graphics("../Pics/krusche_style_diagrams_1.jpg") #https://rmd4sci.njtierney.com/figures-tables-captions-.html
The model of a coin flip

The model of a coin flip

A parameterized model consists of a likelihood function, which specifies the probability of data given the parameter values, and a prior distribution, which specifies the probability (i.e., credibility) of candidate parameter values without taking into account the data.

\[ \pi_S (\theta \mid \tilde{y}) = \frac{\pi_S(\tilde{y} \mid \theta)}{\pi_S(\tilde{y})} \pi_S(\theta) \]

A tool for making such diagrams can be downloaded from Libreoffice and its template. Refer Rasmus’ instructions.

Interpretation of the diagram starts from the bottom. Each arrow of the diagram corresponds to a line of description code for the model.

The format of the model description for JAGS (we will see how in Stan later on) is a string:

modelString = "model {        # open quote for modelString
    for ( i in 1:Ntotal ) {
        y[i] ~ dbern( theta ) # likelihood
    }
    theta ~ dbeta( 1 , 1 )    # prior
}"                            # close quote for modelString

Line 1 of the model describes generation of the data according to the likelihood function: \(y_i \sim dbern(\theta)\).
Line 2 of the model describes generation of the parameter θ from the prior distribution: \(\theta \sim dbeta(\alpha,\beta)\).
In this case parameters of the prior distribution should be defined. For example, \(\alpha = \beta = 1\).

Diagrams like the one in Figure above are very useful for two important reasons:

  1. They help with conceptual clarity, especially as we deal with more complex models. The diagrams capture the conceptual dependencies among data and parameters without getting bogged down with details of the mathematical formulas for the distributions. Although we fully specify relations of the variables in the model, the diagram explicitly spatially connects the corresponding variables so that it is easy to visually comprehend the chain of dependencies among variables.

  2. The diagrams are very useful for implementing the model in JAGS/Stan (later on), because every arrow in the diagram has a corresponding line of code in the JAGS/Stan model specification.

Links: