'run J-test for non-nested models
Parameters
results_x : Result instance
result instance of first model
results_z : Result instance
result instance of second model
attach : bool
If true, then the intermediate results are attached to the instance.
Returns
tstat : float
t statistic for the test that including the fitted values of the
first model in the second model has no effect.
pvalue : float
two-sided pvalue for the t statistic
Notes
Tests of non-nested hypothesis might not provide unambiguous answers.
The test should be performed in both directions and it is possible
that both or neither test rejects. see ??? for more information.
References'

def run(self, results_x, results_z, attach=True):

    if (not np.allclose(results_x.model.endog, results_z.model.endog)):
        raise ValueError('endogenous    variables    in    models    are    not    the    same')
    nobs = results_x.model.endog.shape[0]
    y = results_x.model.endog
    x = results_x.model.exog
    z = results_z.model.exog
    yhat_x = results_x.fittedvalues
    res_zx = OLS(y, np.column_stack((yhat_x, z))).fit()
    self.res_zx = res_zx
    tstat = res_zx.tvalues[0]
    pval = res_zx.pvalues[0]
    if attach:
        self.res_zx = res_zx
        self.dist = stats.t(res_zx.df_resid)
        self.teststat = tstat
        self.pvalue = pval
    return (tstat, pval)
