def calc_F(R, r, beta, var_beta, nobs, df):
 from scipy.stats import f
 hyp = (np.dot(R, beta.reshape(len(beta), 1)) - r)
 RSR = np.dot(R, np.dot(var_beta, R.T))
 q = len(r)
 F = (np.dot(hyp.T, np.dot(inv(RSR), hyp)).squeeze() / q)
 p_value = (1 - f.cdf(F, q, (nobs - df)))
 return (F, (q, (nobs - df)), p_value)

def calc_F ( R , r , beta , var_beta , nobs , df ) : from scipy . stats import f hyp = ( np . dot ( R , beta . reshape ( len ( beta ) , 1 ) ) - r ) RSR = np . dot ( R , np . dot ( var_beta , R . T ) ) q = len ( r ) F = ( np . dot ( hyp . T , np . dot ( inv ( RSR ) , hyp ) ) . squeeze ( ) / q ) p_value = ( 1 - f . cdf ( F , q , ( nobs - df ) ) ) return ( F , ( q , ( nobs - df ) ) , p_value )
computes the standard f-test statistic for linear restriction hypothesis testing parameters r: ndarray restriction matrix r: ndarray restriction vector beta: ndarray estimated model coefficients var_beta: ndarray variance covariance matrix of regressors nobs: int number of observations in model df: int model degrees of freedom returns f value .