How to extract the F statistic and the P value from results.f_test in statsmodels python

user2848498 picture user2848498 · Jul 7, 2014 · Viewed 7k times · Source

I run the OLS.fit() and use the fitted model to get the f value for a particular category like in ANCOVA.

res = OLS.fit()
R = [[0,1,0], [0,0,1]]
res.f_test(R)

The result is in the form of

<F test: F=array([[ 2.21065884]]), p=[[ 0.10971892]], df_denom=5918, df_num=2>

How would I be able to get the F array and the p value from this format? or Is it even possible?

Answer

Josef picture Josef · Jul 7, 2014

Assign the results to store it and then check the attributes.

fres = res.f_test(R)
dir(fres)
fres.fvalue
fres.pvalue

or similar, since I am working with statsmodels master

http://statsmodels.sourceforge.net/devel/generated/statsmodels.regression.linear_model.RegressionResults.f_test.html