Repository navigation
Description
see #1971 for more topic pages in the documentation
(following a bit the discussion in Julia about adding ANOVA type tests
https://groups.google.com/d/msg/pystatsmodels/5w1OAr_OFQg/CiXu72opAQAJ )
We don't have an overview page or notebook in the documentation about what is available.
- wald test: all models
- t_test vectorized single restriction hypothesis
missing multiple testing p-value correction, e.g ENH: t_test_multiple, multiple comparison or testing for regression parameters #3297 - wald_test (and special case f_test) for joint hypothesis
- wald_test_terms : list of hypothesis with single or joint restrictions
- missing: pairwise, joint distribution of several hypothesis
- nonlinear hypothesis ??? where is it, ENH delta method and nonlinear prediction and test #2296 (still open)
- multivariate tests: ?, MANOVA, ...
- t_test vectorized single restriction hypothesis
- LR type test: only for linear model
- compare_lr_test: two given models
- anova_lm: standard ANOVA (F-tests) for linear models
- llnull in discrete, likelihood models (LR test against constant-only model)
- (GMM j-test, test for overidentifying restrictions
- missing : extend to other models
- WIP/missing: GLM deviance and pearson chisquare tests
- missing: QMLE, M-estimator: LR-type test with dispersion in GLM, RLM (LR-type test in a PR)
-
- multivariate tests: ?, cointegration, rank tests
- LM/score test: in linear model, semi-hidden in GLM, correctly specified likelihood assumption
- compare_lm_test in linear regression model, allows robust cov_type (IIRC)
- score_test (in GEE and hiddedn in GLM)
- diagnostic test: linear model only, includes missing variable LM tests
- missing/WIP: full support based on prototype or special case versions.
- conditional moment tests
- mainly specification tests, no proper support except some examples or special cases
- other ???
- CvM tests ?
- ...
- special cases
- tsa : what do we have for hypothesis tests on parameters?
- granger causality
- ...
- tsa : what do we have for hypothesis tests on parameters?
- test on functions of parameters, (not clear how this fits into a categorization)
- exponential form (
eform) - predictions, margins
- ATE, ATT, ...
- ...
- exponential form (
check:
- AnovaRM: is it a wald test or LR-type (F) test?
Almost all of the above is for linear (or affine) hypothesis on the parameters associated with explanatory variables.
Some specification tests reduce to added variable tests (i.e. hypothesis on mean parameters). Other score, LR or CM tests refer to "extra" parameters, e.g. heteroscedasticity tests, test for overdispersion in Poisson, test for zero-inflation, ....
tools:
- estimating models under linear restrictions so we can use LR or score tests: fit_constrained (only in GLM ?)
- zero-restriction omitting parameters: some models don't support general linear constraints, e.g. lags in ARMA and related models
- ...
- missing e.g. drop or add functions for models. stepwise, ...
- missing score and LR test equivalent of wald_test_terms, i.e. drop all terms one or more at a time.
- mostly missing estimation subject to nonlinear constraints
- one step estimation of constrained models: ? where is the helper function to compute constrained params
other inferential
- confidence intervals: in most cases included with the hypothesis tests
- wald : standard, generically supported
- profile loglikelihood (LR): version for GLM in a PR, others?,
- score confidence intervals
- power: nothing yet for models
"Caveats"
- add warnings if cov_type is not "nonrobust", and a LR or score test assumes correctly specified loglike.
Stata raises exception (IIUC the docs) - possible problems with weights: only wald tests are generic,
other types of tests need to watch out for how weights need to be used. Initially not supported.
Activity
josef-pkt commentedon May 18, 2017
a bit related #1718 post-estimation methods equivalent to Stata (issue has not been filled out much)
priority (relatively easy)
possible: we can write some unit tests against
llnullwhich already has unit tests.josef-pkt commentedon May 19, 2017
nlcom in Stata has a
postoption that makes vcov available for further analysis.We could get this easily with linear transformation of parameters or delta method for nonlinear transformation, but all inference is tied into the likelihood Results class, see ENH: InferenceMixin or NoDataModel #3570
josef-pkt commentedon May 19, 2017
Stata's
testshas acoefoption to display the constrained coefficients, i.e. impose constraints on unrestricted params using the cov_params.josef-pkt commentedon May 19, 2017
Stata's `tests command includes option for p-value correction (Bonferroni, ...)
It's easy to do in statsmodels in extra step, but would be nice in t_test summary and summary_frame
Stata also has an option for joint and individual tests (
mtests) in the same table, but for us that is just a call to wald_test and then to t_test with the same restrictions. (I don't think we gain much combining them.)josef-pkt commentedon May 19, 2017
possible method: score test given full model instance and a constrained params. see #1753,
similar to compare_lr_test where we need the identical parameterization, i.e. in contrast to LR test we need the params of the constrained estimate that corresponds to the full model. (this is done internally in fit_constrained)
simple usage cases:
i.e. (IIUC) We use unrestricted params and cov_params to compute constrained params, but then evaluate score and Hessian at the restricted params to compute score test statistics. (two different local quadratic approximations.) maybe useful as shortcut, I don't remember ever having seen this in a reference.
josef-pkt commentedon May 20, 2017
related score confidence intervals #2606 for hypothesis tests #2722 (for GLM)
There isn issue #2077 for comparing the standalone hypothesis tests and confidence interval with the equivalent (except for differences in small sample assumptions) models
e.g. test for proportion versus GLM-Binomial
josef-pkt commentedon May 28, 2017
reminder on kinds of nonlinearities
eform,params_transform_univariate` added in Prediction interval #2151(endpoint confint)
josef-pkt commentedon Jan 14, 2018
usage
https://stackoverflow.com/questions/48097949/statsmodels-patsy-hypothesis-testing-categorical-variable-in-constraint-c
we need an overview of results methods and standalone functions that are available and their usage
e.g. t_test, f_test, wald_test, wald_test_terms,
anova_lm compare_lr_test, compare_lm_test, score_test (not publicized available for GLM)
related:
specification tests on mean function like non-linearity, link-test, ... zero-inflation, ...
josef-pkt commentedon Apr 3, 2018
parking two online references for anova types
http://core.ecu.edu/psyc/wuenschk/StatData/StatData.htm
see pdf file for "Four Types of Sums of Squares for ANOVA Effects"
http://www.matstat.com/ss/#papers
pdf file with an article comparing types of ANOVA (looks good based on reading/skimming a few sections)
and two SAS output files heavily commented, comparison of SAS ANOVA types for 2 and 3 way ANOVA
looks explicit in what is null and alternative
e.g.
type 3 HTI: partial effect of main effect when all higher order terms are included
1305 y = m + a + b + ab + ac + bc + abc
1306 y = m + a + b + c + ab + ac + bc + abc
type 2 SAS ANOVA higher order of other variables are included
1226 y = m + b + c + bc
1227 y = m + a + b + c + bc
HT0 type 2 SAS for two way ANOVA, only main effects
1371 y = m + b + c
1372 y = m + a + b + c
drop all effects: can be obtained with wald_test_terms
i.e. we use full model as alternative H1 and drop several terms to get to the null H0
e.g. drop all terms that include "c":
H0: y = m + a + b + ab
H1: y = m + a + b + c + ab + ac + bc + abc
AFAICS, None of the usual ANOVA types compare SS when several
termsare dropped.I think in general, dropping several terms should reject more often than only including a single dropped effect in the alternative.
(Can we have a case where main effect without interaction effect is insignificant, but interaction effect is significant? I guess so, if interaction effects cancel in the sample/population given the other exog.)
see also issue #3910, where I had misunderstood what anova_lm type 2 does.
AFAICS, R uses the same type 2 definition as SAS, i.e. ignore higher order effect with the same variable
https://stat.ethz.ch/pipermail/r-help/2006-August/111854.html
http://conjugateprior.org/2013/01/formulae-in-r-anova/
partially related
https://www.statmethods.net/stats/anova.html
http://www.personality-project.org/r/r.guide.html#anova
most online explanations for ANOVA types in R are only for 2 way ANOVA
related aside:
The second reference above has an interesting example where we are only interested in the main effect even if there is a significant interaction effect, example is an extended story from a Tukey example.
This is similar to computing ATE, as the population/sample average, and not conditional on subpopulation.
Suppose we have two flavors of a product and need to drop one. We want to know which has the larger effect on sales. Preference for flavor is gender specific, so interaction of flavor and gender is significant.
But we want to estimate the population effect which depends on the gender distribution.
The main effect, running OLS just on flavor and ignoring gender computes the "average effect" that reflects the gender effect averaged over the sample gender distribution. (Assuming random sampling this will also be an estimate of the ATE in the population.)
i.e. What to test depends on what the interesting hypothesis is.