statsmodels/statsmodels — pull request #2097 by jseabold (2014-11-17 21:09:25+00:00)
Title: BUG: Make sure RE names are properly handled.

Fixes the issue mentioned on the mailing list about RE names. This needs tests. It would be great if someone else wrote those tests, because I don't know what the 'correct' output is necessarily supposed to be. This matches the approach in the code before I refactored it so that the wrappers work, there was a thinko, and the stuff in from_formula needs to be handled differently for now unfortunately. MWE

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

data = sm.datasets.get_rdataset('dietox', 'geepack').data

data['constant'] = 1
mod = sm.MixedLM(data['Weight'], data[['constant', 'Time']],
groups=data['Pig'], exog_re=data[['constant', 'Time']])
modf = mod.fit()
print modf.summary()
print modf.params

mod = smf.mixedlm('Weight ~ Time', data, groups = 'Pig', re_formula = '~Time')
modf = mod.fit()
print modf.summary()
print modf.params