Skip to content

add sanity check method to models #1908

Open

Description

@josef-pkt

silly user mistake, using the wrong data #1907

besides the open issues that we have on dtype checking (for example with object arrays) there are other problems that we could either explicitly check for, or we add helper functions or methods that do the basic sanity checks of the data for the user.

FAQ: Why does my model not work?
Answer: run model.sanity_check

(we also have an issue for statistical "sanity" check, i.e. run a battery of diagnostics on the model or results.)

Activity

  1. kshedden commented on Aug 19, 2014

    @kshedden
    Contributor

    I have been wanting something like this. There are a number of useful sanity checks for the models I have been working on.

  2. added this to the 0.8 milestone on Jan 11, 2016
  3. josef-pkt commented on Jan 11, 2016

    @josef-pkt
    MemberAuthor

    I'm thinking about this again.

    to get started:

    checks of exog like

    • rank, condition number, vif, badly scaled (mean, variance) (e.g. should catch integer representation of datetime) (*)
    • restriction imposed by model, e.g. no constant (unless it's already checked somewhere else)
    • check of endog: not clear yet. domain violation should raise or warn earlier ?
    • checking other arrays in some models ?

    checks like the following should be caught automatically and raise or warn earlier:

    • isfinite, but should be added as missing=raise as new default
    • dtypes if dataframe was used

    returns a instance of a simple class, attaches results as attributes and has informative __str__.
    This could also add some basic description of the model, i.e. nobs, k_vars, name of model, ...

    should be extendable, and maybe add a what='all' keyword if there are expensive things and users just want something light or something specific. (add note in docstring)

    (*) threshold for adding a warning statement will be very rough: bad scaling causes problems in Poisson very quickly but not in OLS

  4. josef-pkt commented on Feb 18, 2016

    @josef-pkt
    MemberAuthor

    bump a bit to get at least started
    http://stackoverflow.com/questions/35490803/logistic-regression-does-not-converge

    it would be much easier to point to a method that users can use to do some basic checks on the data. Collinearity checks are in one of my PRs.

  5. josef-pkt commented on Nov 10, 2016

    @josef-pkt
    MemberAuthor

    specific to categorical data:

    we should have a statistic for how many observations we have at each level or category. If we have only a few observations, then the results will noisy.
    For checking individual columns of exog, we need to detect which are categorical or have finite support (ok with formula, but need uniques or find mass points to see whether we have general dummies or contrast variables. maybe check (exog == exog.min()).sum(0) to see if there is a mass point, I guess we shouldn't use something like np.unique on likely continuous variables.)

    For full sets of categorical variables and interactions (e.g. in a saturated model for the subset of categorical variables) we or users would need a full pivot table, contingency table or similar. I'm not sure we need it for a given exog in addition to the individual column check.

  6. josef-pkt commented on Feb 4, 2020

    @josef-pkt
    MemberAuthor

    a list of checks and performance measures for models in R
    https://github.com/easystats/performance#comprehensive-model-check
    they, easystats, have several interface packages to make using R models easier

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