Logo

statsmodels.base.model.GenericLikelihoodModelResults.f_test

GenericLikelihoodModelResults.f_test(r_matrix, q_matrix=None, cov_p=None, scale=1.0, invcov=None)

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 x p array where q is the number of restrictions to test and p is the number of regressors in the full model fit. If q is 1 then f_test(r_matrix).fvalue is equivalent to the square of t_test(r_matrix).t

q_matrix : array-like

q x 1 array, that represents the sum of each linear restriction. Default is all zeros for each restriction.

scale : float, optional

Default is 1.0 for no scaling.

invcov : array-like, optional

A qxq matrix to specify an inverse covariance matrix based on a restrictions matrix.

See also

statsmodels.contrasts, statsmodels.model.t_test

Examples

>>> import numpy as np
>>> import 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>

Previous topic

statsmodels.base.model.GenericLikelihoodModelResults.df_modelwc

Next topic

statsmodels.base.model.GenericLikelihoodModelResults.get_nlfun

This Page