statsmodels.genmod.generalized_estimating_equations.NominalGEE.score_test#
- NominalGEE.score_test(params_constrained, k_constraints=None, exog_extra=None, observed=True)#
Score test for restrictions or for omitted variables
The covariance matrix for the score is based on the Hessian, i.e. observed information matrix or optionally on the expected information matrix..
- Parameters:
- params_constrainedarray_like
estimated parameter of the restricted model. This can be the parameter estimate for the current when testing for omitted variables.
- k_constraints
int,optional Number of constraints that were used in the estimation of params restricted relative to the number of exog in the model. This must be provided if no exog_extra are given. If exog_extra is not None, then k_constraints is assumed to be zero if it is None.
- exog_extraarray_like,
optional Explanatory variables that are jointly tested for inclusion in the model, i.e., omitted variables. Columns that are linear combinations of other columns of exog_extra or of exog, for example the linear term in a spline basis, do not add a constraint, see Notes.
- observedbool,
optional If True, then the observed Hessian is used in calculating the covariance matrix of the score. If false then the expected information matrix is used.
- Returns:
- chi2_stat
float chisquare statistic for the score test
- p-value
float P-value of the score test based on the chisquare distribution.
- df
int Degrees of freedom used in the p-value calculation. This is equal to the number of constraints. With exog_extra it is k_constraints plus the rank of exog_extra given exog.
- chi2_stat
Notes
not yet verified for case with scale not equal to 1.
The number of constraints of exog_extra is its rank after projecting out exog. The rank is the number of singular values larger than 1e-7 of the matrix of the residuals of this projection, with each column divided by the norm of the corresponding column of exog_extra. For a single column this is the tolerance of R’s
lm: the column is redundant if the norm of its residual is less than 1e-7 times its norm. For several columns this is not the sequential rule oflm, so a column can be dropped here thatlmkeeps and the other way round. R’sglm, and soanova(..., test="Rao"), uses the tighter tolerancemin(1e-7, epsilon / 1000), which is 1e-11 with the defaultepsilon. It keeps columns that are linearly dependent on other columns up to noise of relative size 1e-9 or 1e-8, which are dropped here.If exog_extra has redundant columns, it is replaced by an orthonormal basis of its columns after projecting out exog. The test statistic is invariant to this change of basis, and the number of constraints is the rank of the basis. If all columns of exog_extra are in the span of exog, a ValueError is raised.
The projection is not weighted. If the model has freq_weights or var_weights, a column that differs from the span of exog only on observations with weights close to zero, for example 1e-12, adds no information to the statistic but is not redundant here, so it is counted in the degrees of freedom.
Changed in version 0.15.1: With exog_extra, the number of constraints is the rank of exog_extra after projecting out exog instead of its number of columns, and the statistic is computed from a basis of the independent part, so both change if columns of exog_extra are redundant. A ValueError is raised if all columns are redundant, if exog_extra has nan or infinite values or if it does not have as many rows as exog.