I'm used to approaching the idea of a hierarchical model from the Bayesian perspective, such as the one developed in Andrew Gelman's book on regression. I find that I can understand these models from the generative model perspective, but I'm having trouble porting that understanding to the classical Generalized Least Squares framework. My question is about whether or not these hierarchical models can be implemented with GLS.
The simplest example I can think of is the following intercept-only hierarchical model. Imagine that we have $J$ groups. We measure a number of units for each group, taking note of some measured quantity, $X$, for each unit.
We then suppose the following model for our observations:
$X_i \sim N(\alpha_{[j]i}, \sigma)$
$\alpha_j \sim N(\mu_a, \sigma_a)$
We can assume some hyperprior over $\mu_a, \sigma_a$. The formulation above with the hyperprior allows us to write down the full posterior over the parameters. A Bayesian approach would be to compute the posteriors over all the parameters, conditioned on the data, using a tool like MCMC or Variational Inference. This sort of analysis would take in my observed $X_i$ and spit out posterior samples of the parameters, from which I could make my inference. This is an attractive method because if a unit is part of two groups, it is not hard to add a second set of cluster variables, priors and hyperpriors to the above model. As far as I understand, no OLS model specification will allow us to estimate the observed model, nor will and WLS model; there is something about the between-unit relationships in the above model which cannot be represented in the OLS or WLS framework.
I'm trying to understand whether this kind of model can be implemented at all in the GLS framework, or if there's some other tool I should be looking for. Of course, there will be no hyperpriors, which is fine. But it seems plausible to me that the above hierarchical model can be specified somehow by the correlation structure between the errors that we feed into a GLS model with our data. I know that GLS and random effects models (which seem to be very similar to the Bayesian Hierarchical methods) are closely related, but I'm having trouble understanding how. Is there some way to specify the covariance matrix, such as the parameter in statsmodels, that lets us estimate the above model? How about Hierarchical models more generally?