deriving likelihood function for hierarchical bayesian model I'm struggling with hierarchical bayesian modeling. I need to derive a full likelihood function for the given hierarchical structure of the model.
$a_{it}|\lambda_i\sim TN(\lambda_i,\beta)$
$x_{it}|\lambda_i,\xi_i,a_{it}\sim Pr\{x_{it}\}$
$\lambda_{i}|\theta,\tau\sim N(\theta,1/\tau)$
$\xi_{i}|\mu,\omega\sim N(\mu,1/\omega)$
with priors for $\theta, \tau,\mu,\omega$ given as well.
Here, the parameters to be estimated are $\theta, \tau,\mu,\omega,\{\lambda_{it}\},\{\xi_{it}\}$ and the data observation is $\{\{a_{it}\},\{x_{it}\}\}$. 
The question is, what is the full likelihood function for this model. What I think is $P(\{a_{it}\},\{x_{it}\}|\theta, \tau,\mu,\omega,\{\lambda_{it}\},\{\xi_{it}\})=P(\{x_{it}\}|\lambda_i,\xi_i,a_{it})*P(\lambda_{i}|\theta,\tau)*P(\xi_{i}|\mu,\omega)$
Is this the right way?
Thanks in advance!
 A: For independent observables $\{x_{it}\}$ and $\{a_{it}\}$, I would write the joint conditional likelihood as
$$
\begin{aligned}
P(\{x_{it}\},\{a_{it}\}|\{\lambda_i\},\{\xi_i\},\beta) = \prod_i TN(a_{it}|\lambda_i,\beta) Pr(x_{it}|\lambda_i,\xi_i)
\end{aligned}
$$
Some comments:


*

*Notice that I've only included mention of the parameters whose values are explicitly needed to specify the likelihood: $\beta, \{\lambda_j\},$ and $\{\xi_k\}$. I've dropped any mention of the hyperparameters. This is because the hyperparameters specify the prior distributions for the parameters, and since we are only writing a likelihood, we don't need the priors. 

*I'm following your indication in the comment that $Pr(x_i)$ should be made conditional the list of $\lambda$s and $\xi$s.

*I've assumed that the observations are statistically independent of each other, so $P(x_1,x_2,\dots,n_n)=\prod_i P(x_i)$.

*The use of $i$ to index the $x, \xi, $ and $\lambda$ variables implies that there is a 1:1 relationship between them. I have preserved that, but don't immediately know what to make of it. There seems to be two parameters for each data point. That's not good. 

*I don't know what the $TN$ function is. Is it just the "normal" normal $N$? 

*It is not clear what the subscript $t$ means. I've preserved it since it doesn't hurt, but it isn't being averaged over, so I'm not sure what it is doing in the model.

*It doesn't make sense for the independent observables $x_{it}$ and $a_{it}$ to be contingent on each other, but this is what you are hinting with your expression $x_{it}|a_{it}, \lambda_i, \xi_i$. I dropped the $a_{it}$ from the conditional.


On the other hand, if you wanted to specify the posterior distribution of the parameters, you would have to include the priors for the parameters, complete with their hyperparameters. But that seems not to be the task.
