statsmodels.stats.diagnostic.compare_cox#
- statsmodels.stats.diagnostic.compare_cox(results_x, results_z, store=False, *, use_namedtuple=None)[source]#
Compute the Cox test for non-nested models
- Parameters:
- results_x
Resultinstance result instance of first model
- results_z
Resultinstance result instance of second model
- storebool,
defaultFalse If true, then the intermediate results are returned.
- use_namedtuplebool,
optional Flag indicating whether to return the results as a
NonNestedTestResultNamedTuple instead of a plain tuple. Whenstore=Truethe NamedTuple holds the same three elements as the legacy tuple, so it unpacks identically and is always returned, with no warning. Whenstore=Falsethe legacy two-element tuple is returned by default and aFutureWarningis issued.Deprecated since version 0.15.0: In release 0.16.0 or after July 2027, whichever is later, the default will change to always return a
NonNestedTestResult. Setuse_namedtuple=Trueto opt in now, oruse_namedtuple=Falseto silence the warning and keep the current return type.
- results_x
- Returns:
NonNestedTestResultIf
use_namedtuple=True, a NamedTuple with fieldststat,pvalue, andres_store(res_storeisNonewhen not computed). SeeNonNestedTestResult.Otherwise(thedeprecateddefault),aplaintuplemadeupof:- tstat
float t statistic for the test that including the fitted values of the first model in the second model has no effect.
- pvalue
float two-sided pvalue for the t statistic
- res_store
ResultsStore,optional Intermediate results. Returned if store is True.
Notes
Tests of non-nested hypothesis might not provide unambiguous answers. The test should be performed in both directions and it is possible that both or neither test rejects. See [1] for more information.
Formulas from [1], section 8.3.4 translated to code
Matches results for Example 8.3 in Greene
References