Skip to content

mnlogit t_test broken, patsy? #669

Closed

Description

@josef-pkt

similar to issue #234 , this time patsy

>>> mlogit_res.t_test(np.ones(mlogit_res._results.cov_params().shape[0]))
Traceback (most recent call last):
  File "<pyshell#15>", line 1, in <module>
    mlogit_res.t_test(np.ones(mlogit_res._results.cov_params().shape[0]))
  File "e:\josef\eclipsegworkspace\statsmodels-git\statsmodels-all-new\statsmodels\statsmodels\base\model.py", line 1133, in t_test
    LC = DesignInfo(self.model.exog_names).linear_constraint(r_matrix)
  File "e:\josef\eclipsegworkspace\charlton\patsy\patsy\design_info.py", line 220, in linear_constraint
    return linear_constraint(constraint_likes, self.column_names)
  File "e:\josef\eclipsegworkspace\charlton\patsy\patsy\constraint.py", line 395, in linear_constraint
    return LinearConstraint(variable_names, coefs)
  File "e:\josef\eclipsegworkspace\charlton\patsy\patsy\constraint.py", line 52, in __init__
    raise ValueError("wrong shape for coefs")
ValueError: wrong shape for coefs

I thought we had fixed t_test during L1 merge, but I'm not sure.

Activity

  1. josef-pkt commented on Feb 17, 2013

    @josef-pkt
    MemberAuthor

    issue #457 is still open, so there is still the problem even without patsy

  2. josef-pkt commented on Jun 15, 2013

    @josef-pkt
    MemberAuthor

    do we have a test case for the new NegativeBinomial which has also an extra parameter?

  3. josef-pkt commented on Jun 15, 2013

    @josef-pkt
    MemberAuthor

    NegativeBinomial appends the extra parameter in __init__

    self.exog_names.append('alpha')

  4. josef-pkt commented on May 9, 2017

    @josef-pkt
    MemberAuthor

    I looked at the names for 2-D params in #3651 (comment)

    It's not as bad as I thought.
    in t_test patsy.DesignInfo is getting the param_names as an argument, and params itself is used later in a dot product.
    So, AFAICS, we just need two extra methods, get_param_names_full, ravel_params or get_params_flat (or some names like that). get_params_flat and get_param_names_full need to know whether to ravel with order="F" or order="C". MNLogit uses "F".

    MultinomialResults already has _get_endog_name

    wald_test works in essentially the same way as t_test

    AFAIK, we don't have 2-D params with extra params (like multinomial)

  5. josef-pkt commented on May 9, 2017

    @josef-pkt
    MemberAuthor

    unittests for this are actually easy to add, I think.
    We have generic test comparing t_test with t_values, pvalues, conf_int, and those already exist for MNLogit.
    statsmodels\base\tests\test_generic_methods.py does not yet have MNLogit included.

    I don't remember the details about VAR.

  6. added this to the 0.9 milestone on May 9, 2017
  7. josef-pkt commented on May 9, 2017

    @josef-pkt
    MemberAuthor

    one more Wald: wald_test_terms

    if the model didn't use formulas, then it uses

    identity = np.eye(len(result.params))
    ....
    for col, name in enumerate(result.model.exog_names)
        constraint_matrix = identity[col]
    

    So we need to adjust the names and the shape of the constraint matrices early on in the method.
    At the end it delegates to wald_test to compute the test results.

    Bonus: We should get test for a row over all columns of params, or on a column over all rows essentially for free. e.g. test whether one exog/term is irrelevant in all endog/equations.

    (This doesn't address what happens in the formula path. That's messier.)

  8. modified the milestones: 0.9, 0.10 on Oct 3, 2017
  9. self-assigned this
    on Jul 24, 2019
  10. modified the milestones: 0.10, 0.11 on Dec 18, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions