# Python Mixed Linear Model Regression Interpretation of the Results

I cannot seem to find a proper guide on how to interpret the results from a Mixed Linear Model Regression.

import statsmodels.api as sm
import statsmodels.formula.api as smf

md = smf.mixedlm("var1 ~ C(Gender) + C(Gender)*Weight + C(Gender)*Height", dataset, groups=dataset["Gender"])

mdf = md.fit()
print(mdf.summary())


Results:

------------------------------------------------------------------------
Coef.    Std.Err.    z    P>|z| [0.025 0.975]
------------------------------------------------------------------------
Intercept                   3.389       1.109  3.057 0.002  1.216  5.561
C(Gender)[T.1]             -0.011       1.578 -0.007 0.995 -3.103  3.082
Weight                     -0.067       0.022 -3.028 0.002 -0.111 -0.024
C(Gender)[T.1]: Weight     -0.021       0.025 -0.844 0.399 -0.071  0.028
Height                      0.104       0.026  4.028 0.000  0.053  0.154
C(Gender)[T.1]: Height     -0.028       0.029 -0.949 0.343 -0.085  0.030


I do not get what is the meaning of groups = ... What am I supposed to define there? Also, when defining the Gender as a categorical variable, so that it takes into account both genders, how do I interpret the results and the interaction effects of both genders? Also, for some help for the meaning of the coefficient based on the p-value.

Thank you in advance for any help!

• First you need to know whether male and female are 0 and 1 or 1 and 0 in your dataset. Suppose that male is 1. You would say that for each unit increase in weight for a male, var1 increases by -0.067 - 0.021 or just -0.067 for females – Cameron Chandler Oct 21 '20 at 22:19

## 1 Answer

groups= is where you specify the grouping variable. The model will then estimate random intercepts for this variable. This should be whatver variable you have repeated measures for. In your case groups=dataset["Gender"] does not make sense, as there are only 2 genders and you are interested in the fixed effects for it.

As for interpretation, as @Cameron menionted, it depends whether male or female is 0 or 1 respectively. Even when you code a variable and v=categorical, under the hood it will still have a refernce level (which is the one that is 0).

So let's say that male is 0 and female is 1.

3.389 is the expected value of var1 when Weight and Height are both zero, for males.

0.067 is the estimated change in var1 for a 1 unit change in Weight when Height is zero, for males.

0.104 is the estimated change in var1 for a 1 unit change in Height when Weight is zero, for males.

0.021 is the difference in var1 between males and females for a 1 unit change in Weight. This can be thought of as the difference in the slope for Weight between males and females.

0.028 is the difference in var1 between males and females for a 1 unit change in Height. This can be thought of as the difference in the slope for Height between males and females.

Since the main effects are conditional on the numeric variables being at zero, when they are involved in an interaction, it often makes sense to centre these variables around the mean so that they take on a more meaninfgul interpretation.

Each p value is the probability of obtaining the corresponding estimate, or one more extreme, if the effect in the population was actually zero. For example if the association of Weight with var1, in males, when Height is actually zero, then the probability of finding the estimate of -0.067 or lower, is 0.002.