0

The following page gives an example of f-test in statsmodels: f_test

>>> 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:,:]

Say that I modify the second example from the link, so that it becomes:

>>> from statsmodels.datasets import longley
>>> from statsmodels.formula.api import ols
>>> dta = longley.load_pandas().data
>>> formula = 'TOTEMP ~ UNEMP.shift(1) + UNEMP.shift(2) + UNEMP.shift(3) '
>>> results = ols(formula, dta).fit()

How do I write the code to test whether the UNEMP lags are jointly significant?

Djpengo
  • 379
  • 2
  • 14
  • 1
    You can use `results.fvalue` and `results.f_pvalue` to get the joint test that all regressors excluding the intercept are 0. – Kevin S Nov 18 '21 at 00:11
  • Thanks! I'm using statsmodels for logit estimation, which does not have .fvalue parameter. Any ideas on how to use the matrix restriction? – Djpengo Nov 23 '21 at 21:42
  • 1
    Assuming you have a constant in the first position (so you don't want to test), you can test that all coefficients are 0 (ex the constant) using `res.wald_test(np.eye(res.params.shape[0]-1, res.params.shape[0], 1))`. – Kevin S Nov 25 '21 at 09:53

0 Answers0