Compute an Fcontrast/F-test for a contrast matrix.
Here, matrix r_matrix is assumed to be non-singular. More precisely,
r_matrix (pX pX.T) r_matrix.T
is assumed invertible. Here, pX is the generalized inverse of the design matrix of the model. There can be problems in non-OLS models where the rank of the covariance of the noise is not full.
Parameters : | r_matrix : array-like
q_matrix : array-like
scale : float, optional
invcov : array-like, optional
|
---|
See also
scikits.statsmodels.contrasts, scikits.statsmodels.model.t_test
Examples
>>> import numpy as np
>>> import scikits.statsmodels.api as sm
>>> data = sm.datasets.longley.load()
>>> data.exog = sm.add_constant(data.exog)
>>> results = sm.OLS(data.endog, data.exog).fit()
>>> A = np.identity(len(results.params))
>>> A = A[:-1,:]
This tests that each coefficient is jointly statistically significantly different from zero.
>>> print results.f_test(A)
<F contrast: F=330.28533923463488, p=4.98403052872e-10, df_denom=9, df_num=6>
Compare this to
>>> results.F
330.2853392346658
>>> results.F_p
4.98403096572e-10
>>> B = np.array(([0,1,-1,0,0,0,0],[0,0,0,0,1,-1,0]))
This tests that the coefficient on the 2nd and 3rd regressors are equal and jointly that the coefficient on the 5th and 6th regressors are equal.
>>> print results.f_test(B)
<F contrast: F=9.740461873303655, p=0.00560528853174, df_denom=9, df_num=2>