Skip to content

BUG/DOC: stats.api add missing and review #7013

Open

Description

@josef-pkt

I forgot to put the new stats functions into stats.api

Those need to be added, but there might be also other missing or outdated parts

Activity

  1. josef-pkt commented on Sep 1, 2020

    @josef-pkt
    MemberAuthor

    here is a list of the current content of dir(stats.api), without __ objects

                        name                                module                
    98                             tukeyhsd    statsmodels.sandbox.stats.multicomp
    88                       runstest_2samp         statsmodels.sandbox.stats.runs
    87                       runstest_1samp         statsmodels.sandbox.stats.runs
    15                                 Runs         statsmodels.sandbox.stats.runs
    74                            normal_ad              statsmodels.stats._adnorm
    14                        RegressionFDR            statsmodels.stats._knockoff
    63                           lilliefors          statsmodels.stats._lilliefors
    25                             anova_lm                statsmodels.stats.anova
    16                          SquareTable   statsmodels.stats.contingency_tables
    21                             Table2x2   statsmodels.stats.contingency_tables
    20                                Table   statsmodels.stats.contingency_tables
    17                      StratifiedTable   statsmodels.stats.contingency_tables
    33                           cochrans_q   statsmodels.stats.contingency_tables
    69                              mcnemar   statsmodels.stats.contingency_tables
    48                          cov_nearest    statsmodels.stats.correlation_tools
    37                         corr_clipped    statsmodels.stats.correlation_tools
    38                         corr_nearest    statsmodels.stats.correlation_tools
    7                     FactoredPSDMatrix    statsmodels.stats.correlation_tools
    39                  corr_nearest_factor    statsmodels.stats.correlation_tools
    40                     corr_thresholded    statsmodels.stats.correlation_tools
    49             cov_nearest_factor_homog    statsmodels.stats.correlation_tools
    4                              Describe     statsmodels.stats.descriptivestats
    36                            compare_j           statsmodels.stats.diagnostic
    91                           spec_white           statsmodels.stats.diagnostic
    64                linear_harvey_collier           statsmodels.stats.diagnostic
    65                            linear_lm           statsmodels.stats.diagnostic
    60                   het_goldfeldquandt           statsmodels.stats.diagnostic
    86               recursive_olsresiduals           statsmodels.stats.diagnostic
    61                            het_white           statsmodels.stats.diagnostic
    35                 compare_encompassing           statsmodels.stats.diagnostic
    67                         linear_reset           statsmodels.stats.diagnostic
    66                       linear_rainbow           statsmodels.stats.diagnostic
    58                             het_arch           statsmodels.stats.diagnostic
    59                     het_breuschpagan           statsmodels.stats.diagnostic
    0                            CompareCox           statsmodels.stats.diagnostic
    31                        breaks_hansen           statsmodels.stats.diagnostic
    30                 breaks_cusumolsresid           statsmodels.stats.diagnostic
    1                              CompareJ           statsmodels.stats.diagnostic
    9                     HetGoldfeldQuandt           statsmodels.stats.diagnostic
    34                          compare_cox           statsmodels.stats.diagnostic
    22                acorr_breusch_godfrey           statsmodels.stats.diagnostic
    23                       acorr_ljungbox           statsmodels.stats.diagnostic
    24                             acorr_lm           statsmodels.stats.diagnostic
    32                 chisquare_effectsize                  statsmodels.stats.gof
    78                     powerdiscrepancy                  statsmodels.stats.gof
    57               gof_chisquare_discrete                  statsmodels.stats.gof
    10                            Mediation            statsmodels.stats.mediation
    90                               se_cov       statsmodels.stats.moment_helpers
    73                        multipletests            statsmodels.stats.multitest
    12                     NullDistribution            statsmodels.stats.multitest
    55               fdrcorrection_twostage            statsmodels.stats.multitest
    54                        fdrcorrection            statsmodels.stats.multitest
    68                            local_fdr            statsmodels.stats.multitest
    13                        OaxacaBlinder               statsmodels.stats.oaxaca
    100                  zt_ind_solve_power                statsmodels.stats.power
    8                     GofChisquarePower                statsmodels.stats.power
    93                   tt_ind_solve_power                statsmodels.stats.power
    18                        TTestIndPower                statsmodels.stats.power
    94                       tt_solve_power                statsmodels.stats.power
    11                       NormalIndPower                statsmodels.stats.power
    5                       FTestAnovaPower                statsmodels.stats.power
    6                            FTestPower                statsmodels.stats.power
    19                           TTestPower                statsmodels.stats.power
    83   proportions_chisquare_pairscontrol           statsmodels.stats.proportion
    28                           binom_tost           statsmodels.stats.proportion
    77                     power_ztost_prop           statsmodels.stats.proportion
    76                     power_binom_tost           statsmodels.stats.proportion
    81                proportions_chisquare           statsmodels.stats.proportion
    29           binom_tost_reject_interval           statsmodels.stats.proportion
    72      multinomial_proportions_confint           statsmodels.stats.proportion
    82       proportions_chisquare_allpairs           statsmodels.stats.proportion
    79                   proportion_confint           statsmodels.stats.proportion
    26                           binom_test           statsmodels.stats.proportion
    85                    proportions_ztost           statsmodels.stats.proportion
    84                    proportions_ztest           statsmodels.stats.proportion
    27           binom_test_reject_interval           statsmodels.stats.proportion
    80                proportion_effectsize           statsmodels.stats.proportion
    51                     cov_white_simple  statsmodels.stats.sandwich_covariance
    41                          cov_cluster  statsmodels.stats.sandwich_covariance
    42                  cov_cluster_2groups  statsmodels.stats.sandwich_covariance
    43                              cov_hac  statsmodels.stats.sandwich_covariance
    44                              cov_hc0  statsmodels.stats.sandwich_covariance
    45                              cov_hc1  statsmodels.stats.sandwich_covariance
    50                         cov_nw_panel  statsmodels.stats.sandwich_covariance
    46                              cov_hc2  statsmodels.stats.sandwich_covariance
    47                              cov_hc3  statsmodels.stats.sandwich_covariance
    75                        omni_normtest            statsmodels.stats.stattools
    62                          jarque_bera            statsmodels.stats.stattools
    53                        durbin_watson            statsmodels.stats.stattools
    3                           DescrStatsW          statsmodels.stats.weightstats
    95                            ttest_ind          statsmodels.stats.weightstats
    96                            ttost_ind          statsmodels.stats.weightstats
    97                         ttost_paired          statsmodels.stats.weightstats
    99                             zconfint          statsmodels.stats.weightstats
    101                               ztest          statsmodels.stats.weightstats
    2                          CompareMeans          statsmodels.stats.weightstats
    102                               ztost          statsmodels.stats.weightstats
    52                           diagnostic                                   None
    56                                  gof                                   None
    70                       moment_helpers                                   None
    71                            multicomp                                   None
    89                  sandwich_covariance                                   None
    92                            stattools                                   None
    
  2. josef-pkt commented on Sep 1, 2020

    @josef-pkt
    MemberAuthor

    e.g. inter-rater is not in api

    current modules in directory

    anova.py
    api.py
    base.py
    contingency_tables.py
    contrast.py     no direct user conten
    correlation_tools.py
    descriptivestats.py
    diagnostic.py
    dist_dependence_measures.py   missing in api
    gof.py
    inter_rater.py   missing?
    knockoff_regeffects.py
    libqsturng   mainly internal, but can be publicly used for pvalues and critical values
    mediation.py
    meta_analysis.py   new
    moment_helpers.py
    multicomp.py
    multitest.py
    multivariate.py   new
    multivariate_tools.py
    nonparametric.py  new-soon
    oaxaca.py   
    oneway.py  new
    outliers_influence.py  mostly model support, but standalone functions
    power.py
    proportion.py
    rates.py    new
    regularized_covariance.py   ?
    robust_compare.py  new
    sandwich_covariance.py
    stattools.py
    tabledist.py   mainly internal
    weightstats.py
    _adnorm.py
    _diagnostic_other.py
    _knockoff.py
    _lilliefors.py
    _lilliefors_critical_values.py
    
  3. josef-pkt commented on Sep 18, 2021

    @josef-pkt
    MemberAuthor

    bump
    I just found again missing in stats.api, e.g. no oneway, no proportion_2indep

    I have PR for those coming

  4. added this to the 0.13 milestone on Sep 18, 2021
  5. josef-pkt commented on Sep 18, 2021

    @josef-pkt
    MemberAuthor

    I think we could remove the individual functions from sandwich_covariance from stats/api.py
    But it might not be really worth it to break backwards compatibility (unlikely though that is). Wait dill sandwiches get a refactoring.

    from . import sandwich_covariance
    from .sandwich_covariance import (
        cov_cluster, cov_cluster_2groups, cov_nw_panel,
        cov_hac, cov_white_simple,
        cov_hc0, cov_hc1, cov_hc2, cov_hc3,
        se_cov
        )
    
  6. josef-pkt commented on Sep 18, 2021

    @josef-pkt
    MemberAuthor

    compare module content with stats.api list

    current status, I already fixed proportion, rates, and multivariate (not in a commit yet)

    Still several modules missing in api, inter_rater, dist_dependence_measures, meta_analysis, ...
    Some may not yet be public like diagnostic_gen (API unclear), or doubtful gof.

    Some only for model support sandwich_covariance, influence via get_influence ?
    Should we put in api only the main public functions that have main access through stats?

    I'm adding inline comments, e.g. "ADD AnovaRM"

    import statsmodels.stats.api as statsapi
    stats_items = dir(statsapi)
    
    import importlib
    for modn in mod_names:
        print()
        print(modn)
        #module = getattr(statsmodels.stats, modn)
        module = importlib.import_module("statsmodels.stats." + modn)
        m = [i for i in dir(module) if i not in stats_items and not i[0] == "_"]
        print(", ".join(m))
        m
    
    anova   ADD AnovaRM, others are helpers
    AnovaRM, AnovaResults, DataFrame, Index, OLS, anova1_lm_single, anova2_lm_single, anova3_lm_single, anova_single, lrange, np, patsy, pd, stats, summary2
    
    contingency_tables DONE
    cache_readonly, iolib, np, pd, sm_exceptions, stats, warnings
    
    contrast   NOT, internal usage
    Contrast, ContrastResults, MultiCompResult, WaldTestResults, clean0, contrastfromcols, fdist, fullrank, np, stats, student_t, t_test_multi, t_test_pairwise, wald_test_noncent, wald_test_noncent_generic
    
    correlation_tools   ???
    Bunch, GaussianMultivariateKernel, IterationLimitWarning, MultivariateKernel, clip_evals, fminbound, iteration_limit_doc, kernel_covariance, np, sparse, svds, warnings
    
    descriptivestats    CLEAN, too many foreign names left in module
    Appender, CATEGORICAL_STATISTICS, DEFAULT_STATISTICS, DEPRECATION_MSG, Description, Docstring, MISSING, NUMERIC_STATISTICS, PANDAS, PERCENTILES, Parameter, QUANTILES, Sequence, SimpleTable, Union, array_like, bool_like, cache_readonly, describe, ds, float_like, int_like, is_categorical_dtype, is_numeric_dtype, lmap, lrange, nancount, nankurtosis, nanpercentile, nanptp, nanskewness, nanuss, np, pd, pd_percentiles, pd_ptp, sign_test, stats, warnings
    
    diagnostic  ADD, main function is kstest_fit, lillifors (included in api) is alias
    Iterable, NESTED_ERROR, OLS, RegressionResultsWrapper, ResultsStore, anderson_statistic, array_like, bool_like, deprecate_kwarg, dict_like, float_like, int_like, kstest_exponential, kstest_fit, kstest_normal, lagmat, np, pd, stats, string_like
    
    diagnostic_gen  LIKELY NOT in 0.13
    HolderTuple, cov_multinomial, np, prob_larger_2ordinal, prob_larger_ordinal_choice, stats, test_chisquare_binning, var_multinomial
    
    dist_dependence_measures ???
    DistDependStat, HypothesisTestWarning, distance_correlation, distance_covariance, distance_covariance_test, distance_statistics, distance_variance, namedtuple, norm, np, pdist, squareform, warnings
    
    effect_size  NOTHING
    Holder, np, special
    
    gof  ???
    chisquare, chisquare_power, gof_binning_discrete, lrange, np, stats
    
    inter_rater  ADD all
    KappaResults, ResultsBunch, aggregate_raters, cohens_kappa, fleiss_kappa, np, stats, to_table
    
    knockoff_regeffects ADD? needed for use in knockoff
    CorrelationEffects, ForwardEffects, OLSEffects, RegModelEffects, RegressionEffects, np
    
    mediation  DONE
    MediationResults, maybe_name_or_idx, np, pd
    
    meta_analysis ADD all
    CombineResults, HolderTuple, combine_effects, effectsize_2proportions, effectsize_smd, np, pd, stats
    
    moment_helpers  NOT ? module itself is included in api
    comb, corr2cov, cov2corr, cum2mc, mc2cum, mc2mnc, mc2mvsk, mnc2cum, mnc2mc, mnc2mvsk, mvsk2mc, mvsk2mnc, np
    
    multicomp  ?  why are they not included, difference between tukeyhsd and pairwise_tukeyhsd ?
    MultiComparison, pairwise_tukeyhsd
    
    multitest  DONE
    a, m, multitest_alias, multitest_methods_names, np
    
    multivariate   DONE
    
    multivariate_tools ???
    Bunch, cancorr, cc_ranktest, cc_stats, np, partial_project
    
    nonparametric   ADD, is there overlap with diagnostic_gen
    HolderTuple, RankCompareResult, cohensd2problarger, np, prob_larger_continuous, rank_compare_2indep, rank_compare_2ordinal, rankdata, rankdata_2samp, stats
    
    oaxaca
    OLS, OaxacaResults, add_constant, dedent, np
    
    oneway   DONE
    
    outliers_influence
    Appender, GLMInfluence, MLEInfluence, OLS, OLSInfluence, cache_readonly, defaultdict, lzip, maybe_unwrap_results, np, outlier_test, reset_ramsey, summary_table, variance_inflation_factor
    
    power  ?  normal_power_het, normal_sample_size_one_tail are new(ish)
    Power, brentq_expanding, ftest_anova_power, ftest_power, normal_power, normal_power_het, normal_sample_size_one_tail, np, optimize, stats, ttest_power
    
    proportion   DONE
    AllPairsResults, score_test_proportions_2indep, std_prop
    
    rates   DONE
    
    regularized_covariance  ADD
    OLS, RegularizedInvCovariance, np
    
    robust_compare  ADD
    TrimmedMean, np, numbers, scale_transform, trim_mean, trimboth
    
    sandwich_covariance
    S_crosssection, S_hac_groupsum, S_hac_simple, S_nw_panel, S_white_simple, combine_indices, cov_crosssection_0, cov_hac_simple, cov_nw_groupsum, group_sums, kernel_dict, lagged_groups, np, weights_bartlett, weights_uniform
    
    stattools  ADD
    ValueWarning, expected_robust_kurtosis, medcouple, np, robust_kurtosis, robust_skewness, stats
    
    tabledist  IGNORE
    Rbf, TableDist, cache_readonly, interp1d, interp2d, np
    
    weightstats   DONE
    cache_readonly, np, stats
    

    specific:
    from ._knockoff import RegressionFDR (in api.py) private module with public class
    Classes in knockoff_regeffects are not included in api, neither module itself.
    Those classes are needed to create a RegressionFDR instance, similar to families, links, norms.

  7. josef-pkt commented on Sep 19, 2021

    @josef-pkt
    MemberAuthor

    another check:
    module names that don't show up in stats.rst in a line with "currentmodule"

    ['anova',
    'contingency_tables',
    'contrast',
    'diagnostic_gen',
    'effect_size',
    'multivariate_tools',
    'regularized_covariance',
    'sandwich_covariance',
    'tabledist']

    sandwich_covariance functions are included from stats: .. currentmodule:: statsmodels.stats
    anova is separate in rst files.
    contingency_tables is in separate contingency_tables.rst
    contrast, tabledist are internal

    that leaves as not included in rst docs:
    'diagnostic_gen', I'm not sure about api yet, I haven't reviewed api, largely in support of get_diagnostic
    'effect_size', has no public functions, _noncentrality_xxx where xxx is t, f and chisquare
    'multivariate_tools', contains partial_project, and older, semi-obsolete cancor functions
    'regularized_covariance',

    RegularizedInvCovariance is not found in rst/html docs, needs to be added, I guess to https://www.statsmodels.org/dev/stats.html#moment-helpers

    The others can stay out of docs for 0.13

  8. josef-pkt commented on Nov 1, 2024

    @josef-pkt
    MemberAuthor

    notebook for checking is maint_check_api_doc.ipynb,
    the version on my computer was modified 2023-02-02

    The "ADD" in the above comment #7013 (comment) are still missing in api.py (I only checked a few).

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