Repository: statsmodels/statsmodels

Issue:
MAINT: numpy version compatibility on py2.7 
I change the test matrix in #4576, to avoid failures with old scipy

In python 2.7 with numpy  1.14.2 an indexing error shows up, 
most likely because of float, in Python 2.7 Python's `round` returns a float, in python 3 an int.

https://travis-ci.org/statsmodels/statsmodels/jobs/373763677

```
=================================== FAILURES ===================================
__________________________ TestVARExtras.test_process __________________________
self = <statsmodels.tsa.vector_ar.tests.test_var.TestVARExtras object at 0x7fda9be7c290>
    def test_process(self):
        res0 = self.res0
        k_ar = res0.k_ar
        fc20 = res0.forecast(res0.endog[-k_ar:], 20)
        mean_lr = res0.mean()
        assert_allclose(mean_lr, fc20[-1], rtol=5e-4)
    
        ysim = res0.simulate_var(seed=987128)
        assert_allclose(ysim.mean(0), mean_lr, rtol=0.1)
        # initialization does not use long run intercept, see #4542
        assert_allclose(ysim[0], res0.intercept, rtol=1e-10)
        assert_allclose(ysim[1], res0.intercept, rtol=1e-10)
    
        n_sim = 900
        ysimz = res0.simulate_var(steps=n_sim, offset=np.zeros((n_sim, 3)),
                                  seed=987128)
        zero3 = np.zeros(3)
        assert_allclose(ysimz.mean(0), zero3, atol=0.4)
        # initialization does not use long run intercept, see #4542
        assert_allclose(ysimz[0], zero3, atol=1e-10)
        assert_allclose(ysimz[1], zero3, atol=1e-10)
    
        # check attributes
        assert_equal(res0.k_trend, 1)
        assert_equal(res0.k_exog_user, 0)
        assert_equal(res0.k_exog, 1)
        assert_equal(res0.k_ar, 2)
    
        irf = res0.irf()
    
        # partially SMOKE test
        if have_matplotlib and MATPLOTLIB_GT_15:
            fig = res0.plotsim()
            plt.close(fig)
            fig = res0.plot_acorr()
            plt.close(fig)
    
            fig = res0.plot_forecast(20)
            fcp = fig.axes[0].get_children()[1].get_ydata()[-20:]
            # Note values are equal, but keep rtol buffer
            assert_allclose(fc20[:, 0], fcp, rtol=1e-13)
            fcp = fig.axes[1].get_children()[1].get_ydata()[-20:]
            assert_allclose(fc20[:, 1], fcp, rtol=1e-13)
            fcp = fig.axes[2].get_children()[1].get_ydata()[-20:]
            assert_allclose(fc20[:, 2], fcp, rtol=1e-13)
            plt.close(fig)
            plt.close('all')
    
            fig_asym = irf.plot()
>           fig_mc = irf.plot(stderr_type='mc', repl=1000, seed=987128)
statsmodels/tsa/vector_ar/tests/test_var.py:707: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
statsmodels/tsa/vector_ar/irf.py:149: in plot
    seed=seed)
statsmodels/tsa/vector_ar/irf.py:299: in errband_mc
    burn=burn, cum=False)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
self = <statsmodels.tsa.vector_ar.var_model.VARResults object at 0x7fda9b1c3e50>
orth = False, repl = 1000, T = 10, signif = 0.05, seed = 987128, burn = 100
cum = False
    def irf_errband_mc(self, orth=False, repl=1000, T=10,
                       signif=0.05, seed=None, burn=100, cum=False):
        """
            Compute Monte Carlo integrated error bands assuming normally
            distributed for impulse response functions
    
            Parameters
            ----------
            orth: bool, default False
                Compute orthoganalized impulse response error bands
            repl: int
                number of Monte Carlo replications to perform
            T: int, default 10
                number of impulse response periods
            signif: float (0 < signif <1)
                Significance level for error bars, defaults to 95% CI
            seed: int
                np.random.seed for replications
            burn: int
                number of initial observations to discard for simulation
            cum: bool, default False
                produce cumulative irf error bands
    
            Notes
            -----
            Lütkepohl (2005) Appendix D
    
            Returns
            -------
            Tuple of lower and upper arrays of ma_rep monte carlo standard errors
    
            """
        neqs = self.neqs
        # mean = self.mean()
        k_ar = self.k_ar
        coefs = self.coefs
        sigma_u = self.sigma_u
        intercept = self.intercept
        # df_model = self.df_model
        nobs = self.nobs
    
        ma_coll = np.zeros((repl, T+1, neqs, neqs))
    
        def fill_coll(sim):
            ret = VAR(sim, exog=self.exog).fit(maxlags=k_ar, trend=self.trend)
            ret = ret.orth_ma_rep(maxn=T) if orth else ret.ma_rep(maxn=T)
            return ret.cumsum(axis=0) if cum else ret
    
        for i in range(repl):
            # discard first hundred to eliminate correct for starting bias
            sim = util.varsim(coefs, intercept, sigma_u,
                              seed=seed, steps=nobs+burn)
            sim = sim[burn:]
            ma_coll[i, :, :, :] = fill_coll(sim)
    
        ma_sort = np.sort(ma_coll, axis=0)  # sort to get quantiles
        index = round(signif/2*repl)-1, round((1-signif/2)*repl)-1
>       lower = ma_sort[index[0], :, :, :]
E       IndexError: only integers, slices (`:`), ellipsis (`...`), numpy.newaxis (`None`) and integer or boolean arrays are valid indices
statsmodels/tsa/vector_ar/var_model.py:1540: IndexError
```


Discussion:

Resolving patch:
diff --git a/statsmodels/tsa/vector_ar/var_model.py b/statsmodels/tsa/vector_ar/var_model.py
--- a/statsmodels/tsa/vector_ar/var_model.py
+++ b/statsmodels/tsa/vector_ar/var_model.py
@@ -1536,9 +1536,11 @@ def fill_coll(sim):
             ma_coll[i, :, :, :] = fill_coll(sim)
 
         ma_sort = np.sort(ma_coll, axis=0)  # sort to get quantiles
-        index = round(signif/2*repl)-1, round((1-signif/2)*repl)-1
-        lower = ma_sort[index[0], :, :, :]
-        upper = ma_sort[index[1], :, :, :]
+        # python 2: round returns float
+        low_idx = int(round(signif / 2 * repl) - 1)
+        upp_idx = int(round((1 - signif / 2) * repl) - 1)
+        lower = ma_sort[low_idx, :, :, :]
+        upper = ma_sort[upp_idx, :, :, :]
         return lower, upper
 
     def irf_resim(self, orth=False, repl=1000, T=10,


Test patch: