Repository navigation
BUG: Make sure RE names are properly handled in MixedLM. - #2097
Conversation
|
You can add a call to I haven't gone through MixedLM yet to add all the generic tests AFAIR. |
|
I'm more concerned that the names are correct re: the parameters they line up with, and I don't want to/can't spend a ton of time figuring it out. |
60535b0 to
bc2c273
Compare
|
That should do it for a cleanup, though there are still issues. I added one of @kshedden's notebook to the repo bc. it doesn't work as is on the wiki, needed a cleanup to be a bit more Pythonic (I already applied these cleanups to the release notes and other examples), and I wanted to get an idea of the actual R syntax, so I could compare. I still can't replicate the profile likelihood example in the original notebook [1], but it doesn't work for me on the old code either. Failures are non-deterministic, so I guess the optimization just isn't that robust for this case. Maybe we should use a different example? The two problems were 1) the dist_low resulted in a negative first leading principal minor. I added a check for this. and 2) it estimates non-PD |
bc2c273 to
28bbf96
Compare
|
I guess I'm just going to remove the profile likelihood stuff from the notebook and merge this unless someone wants to look in to it. |
BUG: Make sure RE names are properly handled in MixedLM.
…xedLM.
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
Closes #2099.
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
Closes #2099.