statsmodels.stats.diagnostic.het_goldfeldquandt#
- statsmodels.stats.diagnostic.het_goldfeldquandt(y, x, idx=None, split=None, drop=None, alternative='increasing', store=False, *, result_object=None)[source]#
Goldfeld-Quandt homoskedasticity test
This test examines whether the residual variance is the same in 2 subsamples.
- Parameters:
- yarray_like
endogenous variable
- xarray_like
exogenous variable, regressors
- idx
int,defaultNone column index of variable according to which observations are sorted for the split
- split{
int,float},defaultNone If an integer, this is the index at which sample is split. If a float in 0<split<1 then split is interpreted as fraction of the observations in the first sample. If None, uses nobs//2.
- drop{
int,float},defaultNone If this is not None, then observations are dropped from the middle part of the sorted series. If 0<split<1 then split is interpreted as fraction of the number of observations to be dropped. Note: Currently, observations are dropped between split and split+drop, where split and drop are the indices (given by rounding if specified as fraction). The first sample is [0:split], the second sample is [split+drop:]
- alternative{“increasing”, “decreasing”, “two-sided”},
default“increasing” This specifies the alternative for the p-value calculation.
- storebool,
defaultFalse Flag indicating to return the regression results
- result_objectbool,
optional Flag indicating whether to return the results as a
GoldfeldQuandtResultNamedTuple instead of a plain tuple. Whenstore=Truethe NamedTuple holds the same four elements as the legacy tuple, so it unpacks identically and is always returned, with no warning. Whenstore=Falsethe legacy three-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
GoldfeldQuandtResult. Setresult_object=Trueto opt in now, orresult_object=Falseto silence the warning and keep the current return type.
- Returns:
GoldfeldQuandtResultIf
result_object=True, a NamedTuple with fieldsfval,pval,ordering, andres_store(res_storeisNonewhen not computed). SeeGoldfeldQuandtResult.Otherwise(thedeprecateddefault),aplaintuplemadeupof:- fval
float value of the F-statistic
- pval
float p-value of the hypothesis that the variance in one subsample is larger than in the other subsample
- ordering
str The ordering used in the alternative.
- res_store
ResultsStore,optional Storage for the intermediate and final results that are calculated
Notes
The Null hypothesis is that the variance in the two sub-samples are the same. The alternative hypothesis, can be increasing, i.e., the variance in the second sample is larger than in the first, or decreasing or two-sided.
Results are identical to R, but the drop option is defined differently. (sorting by idx not tested yet)