Skip to content

Error in accessing mixedlm results with random slopes #2099

Closed

Description

@Auerilas

Per the email thread on the support page, I'm opening an issue describing an error accessing MixedLM results.

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

data = sm.datasets.get_rdataset('dietox', 'geepack').data
mod = smf.mixedlm('Weight ~ Time', data, groups = 'Pig')
modf = mod.fit()
print modf.summary()

When I try to include a random slope, the model runs and gets fitted:

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

but I get the following error:

print modf.summary()

Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "<string>", line 1, in <module>
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/statsmodels/regression/mixed_linear_model.py", line 1954, in summary
sdf = pd.DataFrame(index=self.model.data.param_names, data=sdf)
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pandas-0.15.0_14_g8e0155c-py2.7-macosx-10.9x86_64.egg/pandas/core/frame.py", line 238, in __init__
copy=copy)
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pandas-0.15.0_14_g8e0155c-py2.7-macosx-10.9-x86_64.egg/pandas/core/frame.py", line 371, in _init_ndarray
return create_block_manager_from_blocks([values.T], [columns, index])

File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pandas-0.15.0_14_g8e0155c-py2.7-macosx-10.9-x86_64.egg/pandas/core/internals.py", line 3489, in create_block_manager_from_blocks
construction_error(tot_items, blocks[0].shape[1:], axes, e)
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pandas-0.15.0_14_g8e0155c-py2.7-macosx-10.9-x86_64.egg/pandas/core/internals.py", line 3470, in construction_error
passed,implied))
ValueError: Shape of passed values is (6, 5), indices imply (6, 4)

Activity

  1. jseabold commented on Nov 19, 2014

    @jseabold
    Member

    Will be closed by #2097

  2. added a commit that references this issue on Dec 2, 2014
    e698f30
  3. added this to the 0.6.1 milestone on Feb 17, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions