In Stata 13, there is now the new command "meglm" (multilevel generalized linear models) to analyse hierarchical models. My question is, what is the difference between the "meglm" with family of Guassian and link function of Identity and the mixed linear models ("mixed")?
Solved – Difference between multilevel GLM and mixed linear models when the family is Gaussian and link function is Identity
generalized linear modelmultilevel-analysisstata
Related Solutions
Section 2.2.2.1 from lme4 book
Because each level of sample occurs with one and only one level of batch we say that sample is nested within batch. Some presentations of mixed-effects models, especially those related to multilevel modeling˜[Rasbash et˜al., 2000] or hierarchical linear models˜[Raudenbush and Bryk, 2002], leave the impression that one can only define random effects with respect to factors that are nested. This is the origin of the terms “multilevel”, referring to multiple, nested levels of variability, and “hierarchical”, also invoking the concept of a hierarchy of levels. To be fair, both those references do describe the use of models with random effects associated with non-nested factors, but such models tend to be treated as a special case.
The blurring of mixed-effects models with the concept of multiple, hierarchical levels of variation results in an unwarranted emphasis on “levels” when defining a model and leads to considerable confusion. It is perfectly legitimate to define models having random effects associated with non-nested factors. The reasons for the emphasis on defining random effects with respect to nested factors only are that such cases do occur frequently in practice and that some of the computational methods for estimating the parameters in the models can only be easily applied to nested factors
The Gamma GLM model is:
$$ y \mid X \sim \text{Gamma} (\mu = f(X\beta), \phi) $$
Where $\mu$ is the expectation parameter, and $\phi$ is a dispersion parameter (the dispersion parameter is not estimated in the standard GLM framework), $X\beta$ is the linear predictor, $\beta$ are the parameters learned by the model, and $f$ is called the link function.
Note that, while $X\beta$ is allowed to take any real value, $f(X\beta)$ is modeling the expectation of a Gamma distribution, which must be a positive real number. This is what Python is telling you, the identity function is not guaranteed to map $X\beta$ to a positive real number, so does not always result in a valid mean parameter.
Cool. Thank you! All of my independent variables are positive, real numbers so I'm good to go, right?
Not necessarily, one of your estimated coefficients could be negative (your intercept is very negative).
Would you mind going into a bit more detail on what you mean? Why would the sign of the intercept have any impact on the coefficients? That doesn't make sense to me.
It has an effect on the mean parameter of your conditional Gamma distribution. Remember, your structure equation for the model is:
$$ \mu = f(X \beta) $$
and $\mu$ must be positive. Suppose that it is valid that all the values of your predictor variables be zero (I don't know if this is the case in your data, as I lack context for your features). Then, your prediction for this data point would be:
$$ \mu(x) = f \left( (1, 0, 0, \cdots, 0) \cdot \beta \right) = f(\text{Intercept}) $$
If you are using the identity link function this means that
$$ \mu(x) = \text{Intercept} $$
which is an invalid value of $\mu$ when the intercept is negative.
Again, due to contextual constraints of your data, you may avoid this situation, but it is mathematically possible.
Best Answer
mixed
is explicitly written for this type of model, and is thus a bit more efficient in its implementation (read: quicker) thanmeglm
. Other than that they estimate the same model.