'Tests single or joint hypotheses of the regression parameters using
Empirical Likelihood.
Parameters
b0_vals : 1darray
The hypothesized value of the parameter to be tested
param_nums : 1darray
The parameter number to be tested
print_weights : bool
If true, returns the weights that optimize the likelihood
ratio at b0_vals.  Default is False
ret_params : bool
If true, returns the parameter vector that maximizes the likelihood
ratio at b0_vals.  Also returns the weights.  Default is False
method : string
Can either be \'nm\' for Nelder-Mead or \'powell\' for Powell.  The
optimization method that optimizes over nuisance parameters.
Default is \'nm\'
stochastic_exog : bool
When TRUE, the exogenous variables are assumed to be stochastic.
When the regressors are nonstochastic, moment conditions are
placed on the exogenous variables.  Confidence intervals for
stochastic regressors are at least as large as non-stochastic
regressors.  Default = TRUE
Returns
res : tuple
The p-value and -2 times the log-likelihood ratio for the
hypothesized values.
Examples
>>> import statsmodels.api as sm
>>> data = sm.datasets.stackloss.load()
>>> endog = data.endog
>>> exog = sm.add_constant(data.exog)
>>> model = sm.OLS(endog, exog)
>>> fitted = model.fit()
>>> fitted.params
>>> array([-39.91967442,   0.7156402 ,   1.29528612,  -0.15212252])
>>> fitted.rsquared
>>> 0.91357690446068196
>>> # Test that the slope on the first variable is 0
>>> fitted.el_test([0], [1])
>>> (27.248146353888796, 1.7894660442330235e-07)'

def el_test(self, b0_vals, param_nums, return_weights=0, ret_params=0, method='nm', stochastic_exog=1, return_params=0):

    params = np.copy(self.params)
    opt_fun_inst = _ELRegOpts()
    if (len(param_nums) == len(params)):
        llr = opt_fun_inst._opt_nuis_regress([], param_nums=param_nums, endog=self.model.endog, exog=self.model.exog, nobs=self.model.nobs, nvar=self.model.exog.shape[1], params=params, b0_vals=b0_vals, stochastic_exog=stochastic_exog)
        pval = (1 - stats.chi2.cdf(llr, len(param_nums)))
        if return_weights:
            return (llr, pval, opt_fun_inst.new_weights)
        else:
            return (llr, pval)
    x0 = np.delete(params, param_nums)
    args = (param_nums, self.model.endog, self.model.exog, self.model.nobs, self.model.exog.shape[1], params, b0_vals, stochastic_exog)
    if (method == 'nm'):
        llr = optimize.fmin(opt_fun_inst._opt_nuis_regress, x0, maxfun=10000, maxiter=10000, full_output=1, disp=0, args=args)[1]
    if (method == 'powell'):
        llr = optimize.fmin_powell(opt_fun_inst._opt_nuis_regress, x0, full_output=1, disp=0, args=args)[1]
    pval = (1 - stats.chi2.cdf(llr, len(param_nums)))
    if ret_params:
        return (llr, pval, opt_fun_inst.new_weights, opt_fun_inst.new_params)
    elif return_weights:
        return (llr, pval, opt_fun_inst.new_weights)
    else:
        return (llr, pval)
