Skip to content

DOC/SUMM missing notebooks (outside tsa) #8359

Open

Description

@josef-pkt

What notebooks do we need to add, especially for recently added features?

I don't have an overview and most of my private notebooks are dev notebooks with extra experiments or using outdated pre-merge api.
my 0.14 roadmap #7720
overview postestimation #7707

Activity

  1. added this to the 0.14 milestone on Aug 7, 2022
  2. josef-pkt commented on Aug 7, 2022

    @josef-pkt
    MemberAuthor

    an idea for easier discovery of notebooks:

    Add a section on top of https://www.statsmodels.org/dev/examples/index.html with "recently added notebooks" with just a plain list of notebook links (no plots, screen shots)

    Another idea would be a "What's new" section with plain list of links to notebook.
    The release notes do not have links to notebooks.

  3. josef-pkt commented on Aug 7, 2022

    @josef-pkt
    MemberAuthor
  4. josef-pkt commented on Aug 7, 2022

    @josef-pkt
    MemberAuthor

    related: missing theory and no references in docs, for "Things that I made up"

    example Influence for zero-inflated:
    I have a private dev notebook try_influence_zip.ipynb which prints several warnings about which statistic / variable is used in plots.
    The docstring has a notes section to point out some problems with the generic MLE definition of influence measures
    https://www.statsmodels.org/dev/generated/statsmodels.discrete.count_model.ZeroInflatedPoissonResults.get_influence.html

    The class returned by get_influence is MLEInfluence which does not have references for the generic definitions, e.g. of generalized leverage
    https://www.statsmodels.org/dev/generated/statsmodels.stats.outliers_influence.MLEInfluence.html

  5. josef-pkt commented on Aug 8, 2022

    @josef-pkt
    MemberAuthor

    Notes: notebook/rst docs ? for postestimation overview

    traditional: wald inference and predict
    general: GLM, OLS/WLS have model specific implementation, eg. influence
    MLE models: generic and model specific

    more details mainly for MLE models, currently discrete models and BetaModel

    get_prediction
    get_influence
    get_diagnostic
    get_distribution
    score_test

    work in progress, and not all are available for all main models
    both generic and model specific methods
    experimental, api and, possibly, definitions and defaults will change (e.g. if generic methods are replaced by model specific methods)
    also, there are still some api inconsistencies

    example: Poisson

  6. josef-pkt commented on Aug 16, 2022

    @josef-pkt
    MemberAuthor

    get prediction, wald_nonlinear, deltacov:

    I don't remember what is actually available, beside get_prediction what="xxx".
    e.g. usages similar to margins and prediction average means.
    examples for nonlinear functions, e.g. comparison of two predictions,
    ???

    update
    AFAICS, my latest notebooks when working on the prediction PR 2021-11-27
    check_nonlinear_delta_prediction.ipynb several nonlinear functions, including margins for count models
    try_get_prediction_docvis.ipynb docvis data Cameron/Trivedi book (?), countmodels, predict and some diagnostic

  7. josef-pkt commented on Sep 29, 2022

    @josef-pkt
    MemberAuthor

    hurdle model and related is missing from doc, based on sphinx search
    and I guess also from api
    merged PR is #7973

    My try_truncated_hurdle_count has examples including usage of get_prediction and get_diagnostic for some of the new count models.
    Other than that, I don't know what post-estimation is available and verified

    checking:
    The hurdle, truncated results classes don't define any of the get_xxx methods. Those are inherited from CountResults.
    unit test in test_truncated_model have good coverage for get_prediction and basic coverage for get_diagnostic.
    Also, I don't know if score_test works. (Two part was made to work for BetaModel, but I don't remember about two-submodel cases as in ZI and hurdle models.)

    We need to check inherited get_distribution and get_influence

    post-estimation overview issue #7707 does not include truncated and hurdle models

    naming not clear TruncatedLF
    "L" means left, but I didn't remember why "F"
    comments in PR are not clear, but they mention "fixed" truncation
    This should be added to docstrings

    update
    I think I remember now after working on an example
    "F" stands for truncation point is constant across observation, a fixed truncation point and not observation specific.
    keyword: truncation : int, optional is scalar and cannot be a nobs array
    TruncatedL, without "F", would allow observation specific left truncation points.
    AFAIR, truncation can be at any count in the implementation is (almost ?) fully supported

    get_distribution is not available, res_h.get_distribution() with hurdle model raises
    AttributeError: 'HurdleCountModel' object has no attribute 'get_distribution'

    get influence in hurdle model infl_h = res_h.get_influence() also raises exception with missing model hessian called by MLEInfluence

    ...\statsmodels\statsmodels\base\model.py in hessian(self, params)
        344             The hessian evaluated at the parameters.
        345         """
    --> 346         raise NotImplementedError
        347 
        348     def fit(self, start_params=None, method='newton', maxiter=100,
    
    NotImplementedError:
    

    score_test in hurdle model raises

    linpred = res_h.predict(which="linear")
    res_h.score_test(exog_extra=linpred**2)
    ...
    AttributeError: 'HurdleCountModel' object has no attribute 'score_factor'
    

    checking the zero-truncation submodel

    linpred = res_h.predict(which="linear")
    res_t = res_h.results_count
    res_t.score_test(exog_extra=linpred**2)
    

    raises with shape mismatch, I guess because the truncation model only has the nonzero observations

    res_t = res_h.results_count
    linpred = res_t.predict(which="linear")
    res_t.score_test(exog_extra=linpred**2)
    

    raises with AttributeError: 'TruncatedLFPoisson' object has no attribute 'score_factor'

  8. josef-pkt commented on Sep 29, 2022

    @josef-pkt
    MemberAuthor

    I accidentially closed tab with open edits.

    short version:
    score_test, get_influence and get_distribution raise in hurdle model because of missing, not implemented model methods.
    Similarly for the attached truncated model res_h.results_count. get_influence works but raises when accessing cached attributes.

  9. josef-pkt commented on Oct 8, 2022

    @josef-pkt
    MemberAuthor

    missing docs, examples and unit tests: get_prediction with formula

    We don't have support for creating prediction design matrices for grids (e.g. emmeans, multicolumn margins), mainly because we don't have enough information from the formula design_info, or it will be a lot of work to get the information for what is available (e.g. interaction effects).
    However, users can specify the predict exog, e.g. a grid, using the original data which is preprocessed by the formula transformation in predict.

    AFAIR, I never looked at this with an example for new get_prediction features (dmatrix with existing design_info).

    for example,
    It would be good to have a helper function that creates one observation for each cell of k categorical variables, including interactions defined by the formula. This could be combined with mean for continuous variables, or expanded with a grid or all observations of continuous variables. (predict_at)

    But first we need to check and unit test how much is currently supported. It should work correctly by inheritance, delegation or because new features copied the working existing code.

  10. josef-pkt commented on Jan 9, 2023

    @josef-pkt
    MemberAuthor
  11. josef-pkt commented on Jun 8, 2023

    @josef-pkt
    MemberAuthor

    VAR, vector_ar is also missing a notebook.
    example code is in rst doc, but not in notebook that can be immediately used.
    An old conversion to a notebook (gist) is linked to in #2272 (this version from 2015 is most likely outdated)

  12. josef-pkt commented on Jan 13, 2024

    @josef-pkt
    MemberAuthor

    bump for oneway: still no notebook

    also docstring is stingy on references, e.g. no reference for Yuen trimmed version
    AFAIR, I also used articles that compare anova versions - references for that ?
    https://www.statsmodels.org/dev/generated/statsmodels.stats.oneway.anova_oneway.html#statsmodels.stats.oneway.anova_oneway

    also other functions
    e.g. equivalence_oneway has no references, it only mentions Wellek's Anova

    merged PR is #6789 (rebased version)
    not many references in this and precursor PRs
    superseded PR #6526 has links to other packages, used for unit tests

  13. modified the milestones: 0.14, 0.15 on Jan 13, 2024
  14. josef-pkt commented on Nov 1, 2024

    @josef-pkt
    MemberAuthor

    I was looking for a quick example for t_test, wald_test explanation to link to.
    However, there is no overview notebook.

    They are mentioned in poisson post-estimation notebook.

    The example notebook page should have some general/base notebooks at the beginning.

    Aside:
    docstring examples are inherited. specific model classes do not have model specific example in method docstrings
    e.g.
    https://www.statsmodels.org/dev/generated/statsmodels.miscmodels.ordinal_model.OrderedResults.wald_test_terms.html
    has examples with OLS and Poisson

    copilot provides relatively good answer
    with link to https://www.statology.org/wald-test-python/ (page is very heavy in ads)

    "...\statsmodels\examples\incomplete\ols_tftest.py"
    has examples, old script file without much text

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

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions