Is my understanding of Stan output correct? I have a hierarchical model with two groups. In group i I observe n_i successes from N_i trials, for i=1,2. More specifically,

n_i \mid \lambda_i, N_i \sim Bin(N_i, \lambda_i)

\lambda_i \mid a,b \sim Beta(a,b)

a \sim Half-Normal(9,2), b \sim Half-Normal(1,0.25)

Let \phi = (a,b) and n=(n_1, N_1, n_2, N_2). The posterior for this model is

p(\phi, \lambda_1, \lambda_2 \mid n) \propto p(n \mid \lambda_1, \lambda_2)p(\lambda_1, \lambda_2 \mid \phi)p(\phi) \hspace{1cm} \text{(Equation 1)}.

Using this I can get the marginal distribution of interest:

p(\lambda_2 \mid n) = \int_{\lambda_1}\int_{\phi}p(\phi, \lambda_1, \lambda_2 \mid n)d\phi d\lambda_1 \hspace{1cm} \text{(Equation 2)}.

The Stan output gives me samples of \phi, \lambda_1 and \lambda_2. Are these samples from their marginal distributions? I.e., is the output for \lambda_2 the marginal given by Equation 2? Or am I supposed to consider each sample as a tuple from the joint distribution (\phi, \lambda_1, \lambda_2)?