# Are these Granger-causality F-tests equivalent?

I am comparing results of a Granger causality implementation I wrote in Python to the established package statsmodels, and noticed that the equation implemented has a scaling factor equal to the maximum lag in question, in pseudocode:

F_statistic   =   ( SSR(independent_residuals) - SSR(joint_residuals))   /
( SSR(joint_residuals) * lag * residual_degrees_of_freedom)


Where the independent_residuals are the residuals of an OLS fit using $Y_t$ and $Y_{t-\operatorname{lag}}$ only, and the joint_residuals are the residuals of the OLS fit using $Y_t$, $Y_{t-\operatorname{lag}}$ and also $X_{t-\operatorname{lag}}$.

(The exact lines of code found here, and look like:)

# Granger Causality test using ssr (F statistic)
fgc1 = ((res2down.ssr - res2djoint.ssr) /
res2djoint.ssr / mxlg * res2djoint.df_resid)


I'm not sure I follow the purpose of the lag term, or the rDoF term.

My own implementation takes the simpler form (I believe proposed by Geweke):

F = np.log( np.var(joint_residuals) / np.var(independent_residuals) )


which I am now questioning, and unsure how equivalent they are.

Geweke's form was shown to be equivalent to Transfer Entropy (for Gaussian variables), so I would like to know if this also holds for the other F-statistic formulation.