# Help Needed for MixedLM Regression

**URL:** <https://discuss.python.org/t/help-needed-for-mixedlm-regression/15178>\
**Category:** Python Help\
**Created:** [April 20, 2022, 4:40am UTC](https://discuss.python.org/t/help-needed-for-mixedlm-regression/15178 "2022-04-20T04:40:14Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![moeenbutt](https://avatars.discourse-cdn.com/v4/letter/m/85e7bf/32.png) [@moeenbutt](https://discuss.python.org/u/moeenbutt)\
**Post date:** [April 20, 2022, 4:40am UTC](https://discuss.python.org/t/help-needed-for-mixedlm-regression/15178/1 "2022-04-20T04:40:14Z")

</div>

Hi Everyone!

I am still learning Python and need your help for the Mixed Linear Model Regression code in Python. I am using the following code:

md = smf.mixedlm(“FBI ~ lninspec”, data, groups=data[“HD”])  
mdf = md.fit()  
print(mdf.summary())

Here FBI is my dependent variable, lninspec is my independent variable, and HD is my level.

My dependent variable FBI is a count variable. Therefore, I want to use the Poisson distribution option in this model. I would appreciate it if you help me in this respect.

Best wishes,

Moeen

---

<div class="post-metadata">

**Author:** ![steven.daprano](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/steven.daprano/32/1083_2.png) [@steven.daprano](https://discuss.python.org/u/steven.daprano)\
**Post date:** [April 20, 2022, 6:50am UTC](https://discuss.python.org/t/help-needed-for-mixedlm-regression/15178/2 "2022-04-20T06:50:38Z")

</div>

What’s `smf`?

What does the documentation of `smf.mixedlm` say?

---

<div class="post-metadata">

**Author:** ![moeenbutt](https://avatars.discourse-cdn.com/v4/letter/m/85e7bf/32.png) [@moeenbutt](https://discuss.python.org/u/moeenbutt)\
**Post date:** [April 20, 2022, 7:10am UTC](https://discuss.python.org/t/help-needed-for-mixedlm-regression/15178/3 "2022-04-20T07:10:48Z")

</div>

Sorry, I should have mentioned it.

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

---

<div class="post-metadata">

**Author:** ![steven.daprano](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/steven.daprano/32/1083_2.png) [@steven.daprano](https://discuss.python.org/u/steven.daprano)\
**Post date:** [April 20, 2022, 8:51am UTC](https://discuss.python.org/t/help-needed-for-mixedlm-regression/15178/4 "2022-04-20T08:51:07Z")

</div>

Are you referring to this function?

[https://www.statsmodels.org/dev/generated/statsmodels.regression.mixed\_linear\_model.MixedLM.html](https://www.statsmodels.org/dev/generated/statsmodels.regression.mixed_linear_model.MixedLM.html)

I’m afraid that your question requires more advanced statistics knowledge than I have.

You could try the statsmodels discussion group here:

[https://groups.google.com/group/pystatsmodels](https://groups.google.com/group/pystatsmodels)

---

<div class="post-metadata">

**Author:** ![moeenbutt](https://avatars.discourse-cdn.com/v4/letter/m/85e7bf/32.png) [@moeenbutt](https://discuss.python.org/u/moeenbutt)\
**Post date:** [April 20, 2022, 9:48am UTC](https://discuss.python.org/t/help-needed-for-mixedlm-regression/15178/5 "2022-04-20T09:48:14Z")

</div>

Thanks so much.
