Skip to content

BUG: MixedLM wald tests broken #2100

Closed
Closed

Description

@josef-pkt

t_test, f_test and wald_test raise the same exception

>>> res.wald_test(np.eye(3,5))
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "e:\josef\eclipsegworkspace\statsmodels-git\statsmodels-all-new2_py27\statsmodels\statsmodels\base\model.py", line 1367, in wald_test
    LC = DesignInfo(names).linear_constraint(r_matrix)
  File "build\bdist.win32\egg\patsy\design_info.py", line 87, in __init__
ValueError: bad term slices

>>> len(res.params)
5

>>> res.cov_params().shape
(5, 5)

based on example for #2099 without including #2097

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:

modf.model.data.param_names += ['r']

print modf.summary()

Activity

  1. josef-pkt commented on Nov 20, 2014

    @josef-pkt
    MemberAuthor

    see #436
    my guess: patsy is way to restricted and limited whenever we add a new model type.
    Things don't work automatically if patsy is in the code path, on the other hand it was useful to discover where we need to refactor.

  2. jseabold commented on Nov 20, 2014

    @jseabold
    Member

    Try with #2097. Works for me.

  3. jseabold commented on Nov 20, 2014

    @jseabold
    Member

    This should work in master now. Your script isn't fully reproducible, so I'll let you close it if confirmed.

  4. added this to the 0.7 milestone on Jan 11, 2015
  5. josef-pkt commented on Jan 11, 2015

    @josef-pkt
    MemberAuthor

    I need to check and close for 0.7

  6. josef-pkt commented on Feb 6, 2015

    @josef-pkt
    MemberAuthor

    Ok, it works, at least the code is doing what it is supposed to be doing.

    see #2231 for interpretation and wald tests that include random effects parameters

  7. modified the milestones: 0.6.1, 0.7 on Feb 6, 2015
  8. josef-pkt commented on Feb 6, 2015

    @josef-pkt
    MemberAuthor

    Skipper's fix was backported to 0.6.1 (not 0.7 milestone)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions