Repository navigation
Conversation
|
Good to see this. I never really understood mixed models in R. background question: I fixed it so it seems to work, but I never figured out what the equivalent in R or other packages is, so I could never write unit tests to check what the results are really supposed to be. Do you know what the main difference between Laird/Ware and Laird/Lange/Stram is? If you have a rough idea how useful the sandbox Mixed is, then we can either refactor or delete it. Mixed models are one of the main missing models, but so far none of us understood the statistics well enough to get an implementation for it. |
|
Thanks, somehow I missed that file when searching. I think we are fitting the same model (that is, LairdWare and Laird/Lange/Stram are using the same model). The latter gets into connections between EM and IRLS, and talks about ways to accelerate EM. I'm not that knowledgeable about this area, but I think the other packages (like LMER) have not made much use of these modified EM strategies, but instead use gradient methods. The sandbox implementation is all EM, whereas mine uses a few EM steps followed by gradient methods. The latter should be much faster, and having an analytic score function is useful for other purposes. EM is very useful for getting a rough starting value. The sandbox code uses some sort of IRLS idea to get standard errors that I'm not very familiar with. I am using the numerical Hessian. If you want to test the sandbox code, it should be possible to use the same examples that are in my test set. Both implementations use an unstructured random effects covariance. In the gradient setting, certain structural constraints (like independent variance components) are easy to incorporate. |
There was a problem hiding this comment.
cov_re is undefined according to pylint or eclipse.pydev
|
I fixed the issue with the notebook and did some renaming and other cleanup per suggestions. |
There was a problem hiding this comment.
suggested rename num -> niter niter_sd, niter_em
There was a problem hiding this comment.
just a note: I would find fixed better than free, but we don't have a convention yet.
We will eventually need a consistent pattern for fixing parameters in the API for user.
|
@josef-pkt @kshedden Amazing. Will pull and take a look soonish. |
|
parking a reference looks like a good overview of different assumptions on error correlation structure (and random coefficients) for mixed, repeated measures anova and gee type correlation patterns.
(In sandbox Mixed I try to fake a patterned epsilon covariance matrix by choosing "funny" Z dummies.) Compound symmetry is equivalent to random intercept IIRC. (*) random coefficient (and multilevel) models could be more general than mixed because RC doesn't necessarily assume independence across panel units. (I'm still trying to translate "statistics" into something that I know or have some intuition about.) |
|
We will need to extend MixedLM to accommodate heteroscedastic epsilon. I Non-diagonal structure for cov(epsilon) is getting more into what I Dependence between groups (I think your "panels" are my "groups") is |
|
Yes, I don't expect we will have everything in one model or implemented very fast. Panel PR also implements the simple two random factor model with one random constant per group (panel unit) and one random factor that is a time effect that is random over time but common to all groups (panel units). I don't think I have ever seen more than two "crossed" random factors. Related: similar to random coefficient models I had used it to impose closeness of parameters. For example in the longitudinal setting, we might have parameters/coefficients that change over time, but we want to impose a prior that the parameters don't change too much from period to period. |
|
@kshedden In the last commit you renamed the statsmodels/base/penalties.py module but you forgot to commit the removal of the old one, now both are in the repo. Can you amend the last commit, removing penalties.py, and force push? |
|
Done. On Tue, May 20, 2014 at 11:10 PM, Josef Perktold
|
|
@dengemann Any comments? Did you have a chance to look at it? I'm planning to rebase, and merge after a quick look at it, within a few days or a week. |
|
for rebase: |
|
@josef-pkt please go ahead, I don't have time to review in depth at this point. I'm happy to comment on master later. |
|
@kshedden I looked at your notebook examples again: Is the constant/intercept always included in the random coefficients or can it be excluded? |
|
rebased version is in #1688 |
|
If exog_re is supplied explicitly then no intercept is added. But under On Sat, May 24, 2014 at 4:15 AM, Josef Perktold [email protected]:
|
…ased ENH: Mixed Effects Models closes statsmodels#1398
This is an implementation of linear mixed models, in the style of Laird & Ware (as found in R lme4, SAS proc mixed, etc.). I don't know of other work on this in statsmodels, so this starts from scratch.
Lots of work is still needed, but it converges, and the results agree with R/lme4 on a number of examples.
Major issues: