2

I would like to specify the cov_struct attribute when calling the method MixedLM (statsmodels package) but it doesn't work.

On the contrary, when specifying this parameter to the method GEE (statsmodels), it works!

More precisely :

sm.GEE.from_formula("Y ~ X1 + X2 - 1", data=data,groups=Xg, cov_struct=sm.genmod.cov_struct.Exchangeable()).fit()

works.

But

sm.MixedLM.from_formula("Y ~ X1 + X2 - 1", data=data,groups=Xg, cov_struct=sm.genmod.cov_struct.Exchangeable()).fit()

Does not Work

The error I get is :

{AttributeError}'Exchangeable' object has no attribute 'ndim'

Also, I don t really understand the groups attribute.

1
  • MixedLM does not handle cov_struct yet. Your keyword cov_struct is put into the **kwargs and treated as a data array.
    – Josef
    Commented Mar 19, 2015 at 15:17

1 Answer 1

1

cov_struct is only for GEE. If you want to specify the covariance structure in MixedLM use 're_formula'.

Note that GEE in statsmodels is much more mature than MixedLM.

2
  • Thanks for the answer. By covariance structure you mean covariance matrix I suppose. And what about the "groups" attribute? Can I find a clear documentation somewhere? Commented Mar 23, 2015 at 12:36
  • Quite a few examples are linked to this page. Note in particular the Sitka growth example that uses a random slope. MixedLM does not support time series style covariance structures like AR. The covariance is defined implicitly through the random effects structure. Commented Mar 23, 2015 at 17:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.