Skip to content

ENH/BUG: bootstrap and recreating models #5169

Open

Description

@josef-pkt

This is a specific point of #4679

GenericLikelihoodModel is the only built-in bootstrap method (besides some confint bootstrap in tsa).
There are currently problems, incomplete and outdated support for recreating a model for the bootstrap iteration.

specific case: I don't know how to get bootstrap for the MyPareto unit test cases to work
#5143 (comment)
edit I had printed out from the wrong results instance, everything in bootstrap with constrained model looks fine, although a bit cumbersome to use.

todo:

  • need unit tests that check what attributes, keywords are used in the recreated bootstrap models
  • refactor _init_keys/cloneattr
  • check how constrainted estimation, transform_params is supposed to work with recreating models
  • provide a prototype miscmodel, so we have it documented and have a unit test case for it.

#5143 fixes an issue when exog=None and a problem with cloneattr, however that's incomplete. It also has an example without constraints that seems to work.

Activity

  1. josef-pkt commented on Sep 10, 2018

    @josef-pkt
    MemberAuthor

    bootstrap only stores params and not results instances, i.e. we cannot check from the outside which model attributes are used.

    We don't need cov_params when we only keep params, i.e. we should skip Hessian/cov_params computation if not needed.
    In another bootstrap version, we want to store other things, e.g. pivotal t-statistics, which will need more results.

    GenericLikelihoodModelResults.bootstrap has no user specified fit_kwds.

  2. josef-pkt commented on Nov 4, 2018

    @josef-pkt
    MemberAuthor

    another issue: fit(return="params")` because initializing the results instance can require relatively expensive computation, besides "skip_hessian"
    (e.g. in GAM we need the hat_matrix_diag to estimate effective degrees of freedom)

  3. josef-pkt commented on Jun 12, 2021

    @josef-pkt
    MemberAuthor

    ENH:

    getting other results from bootstrap, currently only mean params and bse/std is included, but we also return all parameter estimates of the bootstrap iterations

    e.g. bootstrap confidence intervals, bootstrap cov, example from a discretized model in #7488
    distribution dp = DiscretizedCount(stats.gamma)

    Note: those use bootstrap parameter estimates directly and are not pivotal.
    Currently we don't compute enough statistics in each bootstrap iteration to get pivotal bootstrap statistics.

    res.params, res.bse, res.pvalues
    (array([3.52635451, 0.42561606]),
     array([0.51737782, 0.06370693]),
     array([9.37271019e-12, 2.37570277e-11]))
    
    res_boots = res.bootstrap()
    res_boots[:2]
    (array([3.64883387, 0.42001672]), array([0.47314425, 0.0545065 ]))
    res_boots[2]
    
    res.conf_int(alpha=0.1)
    array([[2.67534372, 4.3773653 ],
           [0.32082748, 0.53040464]])
    
    [np.percentile(ri, 95, axis=0) for ri in res_boots[2].T]
    [4.51308744241364, 0.522090578890195]
    [np.percentile(ri, 5, axis=0) for ri in res_boots[2].T]
    [2.941160216191393, 0.33520515755256414]
    
    np.cov(res_boots[2].T)
    array([[ 0.22612675, -0.02409635],
           [-0.02409635,  0.00300097]])
    
    res.cov_params()
    array([[ 0.26767981, -0.03142997],
           [-0.03142997,  0.00405857]])
    

    also alternatives to case resampling, e.g. parametric bootstrap

  4. josef-pkt commented on Jun 12, 2021

    @josef-pkt
    MemberAuthor

    docstring Return of bootstrap method is incorrect, it doesn't include results which it always returns.

    not option in bootstrap for fit keywords, e.g. start_params.
    Currently it always starts the fit in each bootstrap iteration with default start_params.

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

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions