# statsmodels.regression.recursive_ls.RecursiveLSResults.f_test¶

RecursiveLSResults.f_test(r_matrix, cov_p=None, invcov=None)

Compute the F-test for a joint linear hypothesis.

This is a special case of wald_test that always uses the F distribution.

Parameters
r_matrix

One of:

• array : An r x k array where r is the number of restrictions to test and k is the number of regressors. It is assumed that the linear combination is equal to zero.

• str : The full hypotheses to test can be given as a string. See the examples.

• tuple : A tuple of arrays in the form (R, q), `q` can be either a scalar or a length k row vector.

cov_parray_like, `optional`

An alternative estimate for the parameter covariance matrix. If None is given, self.normalized_cov_params is used.

invcovarray_like, `optional`

A q x q array to specify an inverse covariance matrix based on a restrictions matrix.

Returns
`ContrastResults`

The results for the test are attributes of this results instance.

`t_test`

Perform a single hypothesis test.

`wald_test`

Perform a Wald-test using a quadratic form.

`statsmodels.stats.contrast.ContrastResults`

Test results.

`patsy.DesignInfo.linear_constraint`

Specify a linear constraint.

Notes

The 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.

Examples

```>>> import numpy as np
>>> import statsmodels.api as sm
>>> 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 test: F=array([[ 330.28533923]]), p=4.984030528700946e-10, df_denom=9, df_num=6>
```

Compare this to

```>>> results.fvalue
330.2853392346658
>>> results.f_pvalue
4.98403096572e-10
```
```>>> B = np.array(([0,0,1,-1,0,0,0],[0,0,0,0,0,1,-1]))
```

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 test: F=array([[ 9.74046187]]), p=0.005605288531708235, df_denom=9, df_num=2>
```

Alternatively, you can specify the hypothesis tests using a string

```>>> from statsmodels.datasets import longley
>>> from statsmodels.formula.api import ols
{"ft_lang_label":"__label__en","ft_lang_prob":0.5650979,"math_prob":0.9781263,"size":2906,"snap":"2022-05-2022-21","text_gpt3_token_len":801,"char_repetition_ratio":0.11164714,"word_repetition_ratio":0.0049875313,"special_character_ratio":0.3086717,"punctuation_ratio":0.20386644,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.9994246,"pos_list":[0],"im_url_duplicate_count":[null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2022-05-18T22:58:45Z\",\"WARC-Record-ID\":\"<urn:uuid:33282e64-dcc7-4608-a4d6-3d1ffc6739f6>\",\"Content-Length\":\"30929\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:1047c865-e829-403f-9862-213b0eb9fd4e>\",\"WARC-Concurrent-To\":\"<urn:uuid:10fa08f9-0c15-4f3b-9413-19cf7d080cf5>\",\"WARC-IP-Address\":\"185.199.110.153\",\"WARC-Target-URI\":\"https://www.statsmodels.org/stable/generated/statsmodels.regression.recursive_ls.RecursiveLSResults.f_test.html\",\"WARC-Payload-Digest\":\"sha1:NCHC3C75XHLIXNNRNN3M53UV24BFKQH5\",\"WARC-Block-Digest\":\"sha1:F3KZRRXTBXSMK54R5AYCDKLIF4BRPSGW\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2022/CC-MAIN-2022-21/CC-MAIN-2022-21_segments_1652662522556.18_warc_CC-MAIN-20220518215138-20220519005138-00236.warc.gz\"}"}