Repository: statsmodels/statsmodels

Issue:
BUG/REF: assignment to slices in numpy >= 1.9 (emplike)
It's not a bug in the sense of producing wrong numbers.
Numpy is changing the behavior for assigment to slices (index or mask based)

Christoph Gohlke tested the numpy 1.9b1 against several packages
http://www.lfd.uci.edu/~gohlke/pythonlibs/tests/20140609-win-amd64-py2.7-numpy-1.9.0b1/statsmodels_test.txt

3 errors, this one is typical

```
======================================================================
ERROR: statsmodels.emplike.tests.test_origin.TestOrigin.test_ci_beta
----------------------------------------------------------------------
Traceback (most recent call last):
  File "X:\Python27-x64\lib\site-packages\nose\case.py", line 197, in runTest
    self.test(*self.arg)
  File "X:\Python27-x64\lib\site-packages\statsmodels\emplike\tests\test_origin.py", line 35, in test_ci_beta
    ci = self.res1.conf_int_el(1)
  File "X:\Python27-x64\lib\site-packages\statsmodels\emplike\originregress.py", line 256, in conf_int_el
    lowerl = optimize.brentq(f, lower_bound, self.params[param_num])
  File "X:\Python27-x64\lib\site-packages\scipy\optimize\zeros.py", line 415, in brentq
    r = _zeros._brentq(f,a,b,xtol,rtol,maxiter,args,full_output,disp)
  File "X:\Python27-x64\lib\site-packages\statsmodels\emplike\originregress.py", line 255, in <lambda>
    stochastic_exog=stochastic_exog)[0] - r0
  File "X:\Python27-x64\lib\site-packages\statsmodels\emplike\originregress.py", line 202, in el_test
    return_weights=return_weights)
  File "X:\Python27-x64\lib\site-packages\statsmodels\regression\linear_model.py", line 1519, in el_test
    stochastic_exog=stochastic_exog)
  File "X:\Python27-x64\lib\site-packages\statsmodels\emplike\elregress.py", line 58, in _opt_nuis_regress
    params[nuis_param_index] = nuisance_params
ValueError: shape mismatch: value array of shape (2,) could not be broadcast to indexing result of shape (0,)
```

(quoting parts of my post to numpy mailing list)

params[nuis_param_index] = nuisance_params
ValueError: shape mismatch: value array of shape (2,) could not be
broadcast to indexing result of shape (0,)

As far as I have figured out based on Christoph's test failures

`nuis_param_index`  is array([], dtype=int32)
and because numpy didn't assign anything, `nuisance_params` was picked
essentially arbitrary along this code path

```
>>> x = np.arange(5.)
>>> we_dont_care_what_this_is = np.random.randn(10)
>>> x[[]] = we_dont_care_what_this_is
>>> x
array([ 0.,  1.,  2.,  3.,  4.])
```

It looks like fix is simply to use `[]` for the `nuisance_params` in this case (there are none) in linear_model.OLSResults.el_test

```
        if len(param_nums) == len(params):
            llr = opt_fun_inst._opt_nuis_regress([]
```

all emplike/tests pass on my computer



Discussion:
we don't have a specific `comp-emplike` label for git issues


Resolving patch:
diff --git a/statsmodels/regression/linear_model.py b/statsmodels/regression/linear_model.py
--- a/statsmodels/regression/linear_model.py
+++ b/statsmodels/regression/linear_model.py
@@ -2115,7 +2115,7 @@ def el_test(self, b0_vals, param_nums, return_weights=0,
         params = np.copy(self.params)
         opt_fun_inst = _ELRegOpts() # to store weights
         if len(param_nums) == len(params):
-            llr = opt_fun_inst._opt_nuis_regress(b0_vals,
+            llr = opt_fun_inst._opt_nuis_regress([],
                                     param_nums=param_nums,
                                     endog=self.model.endog,
                                     exog=self.model.exog,


Test patch: