OiO.lk Community platform!

Oio.lk is an excellent forum for developers, providing a wide range of resources, discussions, and support for those in the developer community. Join oio.lk today to connect with like-minded professionals, share insights, and stay updated on the latest trends and technologies in the development field.
  You need to log in or register to access the solved answers to this problem.
  • You have reached the maximum number of guest views allowed
  • Please register below to remove this limitation

How to specify more than one groups in statsmodels mixedlm

  • Thread starter Thread starter Samvel Mkhitaryan
  • Start date Start date
S

Samvel Mkhitaryan

Guest
I'm trying to fit a mixed effects model in statsmodels mixedlm and have a bit of a trouble with translating the formula from R to Python. How can I specify this model from R lmer in statsmodels mixedlm.

Code:
data(dietox, package='geepack')

lm_sl = lmer('Weight ~ Time + (Time|Litter) + (Time|Pig)', 
             data=df)

I would expect to see the estimates of random slopes and random intercepts per groups (Litter and Pig). Something similar to this output from R: coef(lm_sl)$Pig, coef(lm_sl)$Litter
<p>I'm trying to fit a mixed effects model in statsmodels mixedlm and have a bit of a trouble with translating the formula from R to Python. How can I specify this model from R lmer in statsmodels mixedlm.</p>
<pre><code>data(dietox, package='geepack')

lm_sl = lmer('Weight ~ Time + (Time|Litter) + (Time|Pig)',
data=df)
</code></pre>
<p>I would expect to see the estimates of random slopes and random intercepts per groups (Litter and Pig). Something similar to this output from R: <code>coef(lm_sl)$Pig</code>, <code>coef(lm_sl)$Litter</code></p>
 

Latest posts

Top