Skip to content

missing in extra data (example sandwiches, robust covariances) #1220

Open

Description

@josef-pkt

see comments #863

The sandwich calculations require additional arrays like groups or time.

If patsy or statsmodels missing='drop' removes the rows with missing, then the data of the user doesn't match up with the cleaned endog, exog.

Currently the user needs to drop rows to get consistent matching data for all variables. (it's just a dropna() when using pandas)

Instead we can drop internally, if missing='drop' and we have the index of the dropped rows.

Activity

  1. josef-pkt commented on Jun 16, 2014

    @josef-pkt
    MemberAuthor

    we should just get a helper function that checks and converts/adjusts extra arrays for missing values, based on the stored information about which rows have been dropped or kept.

  2. added this to the 0.6 milestone on Aug 12, 2014
  3. josef-pkt commented on Aug 12, 2014

    @josef-pkt
    MemberAuthor

    adding 0.6, if this is not easy to add, we drop it again from 0.6 milestone

  4. jseabold commented on Oct 9, 2014

    @jseabold
    Member

    Is there an example that demonstrates the problem somewhere for a test?

  5. jseabold commented on Oct 15, 2014

    @jseabold
    Member

    Should be closed by #2034. A test case here would be helpful. Re-open if still present.

  6. josef-pkt commented on Nov 15, 2015

    @josef-pkt
    MemberAuthor

    reopening

    #2034 fixed the handling of extra arrays in model.__init__, but cov_type, cov_kwds are fit arguments, and don't have the missing value connection yet.
    http://stackoverflow.com/questions/33712400/statsmodels-ols-clustered-standard-errors-not-accepting-series-from-df

    We can add the check to cov_type handling for the case where the original and the cov arrays have matching pandas indices, and there are no extra missing values in the cov_kwd Series or DataFrame, In all other case we don't have enough information to adjust the cov_kwd data and need to raise an exception.

  7. modified the milestones: 0.10, 0.6 on May 27, 2017
  8. jbrockmendel commented on May 27, 2017

    @jbrockmendel
    Contributor

    Is this related to the place(s) in ModelData.__init__ that run self.__dict__.update(...)?

  9. josef-pkt commented on May 27, 2017

    @josef-pkt
    MemberAuthor

    @jbrockmendel No, I think not.
    According to my last comment here, extra arrays in a model.__init__ are or can be handled by the missing check. that's why the issue was closed. (I don't know if every model with extra arrays already uses this.)

    However, the problem is that we get now additional arrays or pandas equivalents in fit cov_kwds for panel and cluster cov_types. Those are currently not checked for whether the original data had rows removed because of missing value handling. Those arrays also never go through model.data handling.

    I moved it to 0.10 because it will be a bit messy and users can work around by just using dropna() on their initial dataframe. (I still think users are better off to dropna themselves than to push it into the model.)

    aside:
    The missing=drop option in __init__ checks all arrays for any missing in each row. In fit arrays, we already have the model and cannot work if there are any additional missing values. However it will be possible to adjust for the missing that were removed in __init__ if we have the matching index.

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