Repository: statsmodels/statsmodels

Issue:
32 bit wheels failing over on statsmodels wheels
#### Describe the bug

The linux 3.5 and 3.6 32 bit builds are failing because of an uncaught warning. Does anyone have any idea why this would be? Anything change with warnings on 32 bit systems? 

The Windows 32 bit builds seem to be fine. 

(cron job) https://travis-ci.org/MacPython/statsmodels-wheels/builds/560978928
(my attempt) https://travis-ci.org/thequackdaddy/statsmodels-wheels/builds/561402830
(my attempt) https://ci.appveyor.com/project/thequackdaddy/statsmodels-wheels/builds/26122430

I doubt we have very many linux 32 bit users. We could just end support for that too. 


Discussion:
My guess is that the error is not being tripped here... 

https://github.com/statsmodels/statsmodels/blob/32011b6b5e89e1e9d8061cd210406790d4ee7430/statsmodels/base/model.py#L1292-L1306

Reading this and the failing test code... 

https://github.com/statsmodels/statsmodels/blob/32011b6b5e89e1e9d8061cd210406790d4ee7430/statsmodels/base/tests/test_generic_methods.py#L255-L263

I *think* the tvalues part should have already been cached, so I'm wondering if this is an issue with `norm.sf` or `t.sf`. Not sure and setting up a i686 linux instance is really not something I'm too interested in at the moment. Only a theory. 
I think it is a bug in one of the libraries that is being used. It isn't possibly the res1.tvalues is called earlier since res1 has only been defined a few lines above.  Could you bump the final dot version so that 1.14.0->1.14.6?
Another option could be to use `with np.errstate(invalid='warn')` as a context manager around this, although it shouldn't be necessary.
You don’t think it’s an issue with the lack of a warning from norm.sf or t.sf? 
I think these runtime warnings all come from NumPy.
So I upgraded to even the newest numpy/scipy and still get the errors. 

I think this was actually introduced quite recently... but we didn't notice it because we don't test on 32 bit linux. 

https://github.com/statsmodels/statsmodels/commit/3d14a28e39d078cf72b607ba0289aee11da9b82d#diff-111b086716e2864b120e1f451a7829f2
We could simply skip these tests on 32-bit unix.
@jbrockmendel I think the p-value checks are wrong in the sense that SciPy doesn't universally produce them. I get them on Windows but on Linux (checked both 32 bit and 64 bit). These need to be rolled back. 
Windows

```
$  python -c "import numpy;import scipy.stats;scipy.stats.norm.cdf(numpy.array([numpy.nan]));print('done')"
C:\Anaconda\lib\site-packages\scipy\stats\_distn_infrastructure.py:877: RuntimeWarning: invalid value encountered in greater
  return (self.a < x) & (x < self.b)
C:\Anaconda\lib\site-packages\scipy\stats\_distn_infrastructure.py:877: RuntimeWarning: invalid value encountered in less
  return (self.a < x) & (x < self.b)
C:\Anaconda\lib\site-packages\scipy\stats\_distn_infrastructure.py:1748: RuntimeWarning: invalid value encountered in greater_equal
  cond2 = (x >= self.b) & cond0
done

```

Linux
```
python -c "import numpy;import scipy.stats;scipy.stats.norm.cdf(numpy.array([numpy.nan]));print('done')"
done
```
Should we report this to the fine folks over on scipy? 
Could be worth a shot, although this won't help us here.  I suspect this is due to compiler specific issues and platform libraries.  I'll report it.

Resolving patch:
diff --git a/statsmodels/compat/platform.py b/statsmodels/compat/platform.py
--- a/statsmodels/compat/platform.py
+++ b/statsmodels/compat/platform.py
@@ -1,8 +1,12 @@
 import os
 import sys
 
-__all__ = ['PLATFORM_OSX', 'PLATFORM_WIN', 'PLATFORM_WIN32']
+__all__ = ['PLATFORM_OSX', 'PLATFORM_WIN', 'PLATFORM_WIN32', 'PLATFORM_32',
+           'PLATFORM_LINUX', 'PLATFORM_LINUX32']
 
 PLATFORM_OSX = sys.platform == 'darwin'
 PLATFORM_WIN = sys.platform in ('win32', 'cygwin') or os.name == 'nt'
 PLATFORM_WIN32 = PLATFORM_WIN and sys.maxsize < 2**33
+PLATFORM_LINUX = sys.platform[:5] == 'linux'
+PLATFORM_32 = sys.maxsize < 2 ** 33
+PLATFORM_LINUX32 = PLATFORM_32 and PLATFORM_LINUX


Test patch:
diff --git a/statsmodels/base/tests/test_generic_methods.py b/statsmodels/base/tests/test_generic_methods.py
--- a/statsmodels/base/tests/test_generic_methods.py
+++ b/statsmodels/base/tests/test_generic_methods.py
@@ -11,7 +11,7 @@
 Author: Josef Perktold
 """
 from statsmodels.compat.pandas import assert_series_equal, assert_index_equal
-from statsmodels.compat.platform import PLATFORM_OSX
+from statsmodels.compat.platform import PLATFORM_OSX, PLATFORM_LINUX32
 
 import numpy as np
 import pandas as pd
@@ -112,9 +112,14 @@ def test_zero_constrained(self):
             tvals1 = res1.tvalues[keep_index_p]
         assert_allclose(tvals1, res2.tvalues, rtol=tol, atol=tol)
 
-        with pytest.warns(RuntimeWarning, match="invalid value encountered"):
-            # passing NaN into scipy.stats functions
+        # See gh5993
+        if PLATFORM_LINUX32:
             pvals1 = res1.pvalues[keep_index_p]
+        else:
+            with pytest.warns(RuntimeWarning,
+                              match="invalid value encountered"):
+                # passing NaN into scipy.stats functions
+                pvals1 = res1.pvalues[keep_index_p]
         assert_allclose(pvals1, res2.pvalues, rtol=tol, atol=tol)
 
         if hasattr(res1, 'resid'):
@@ -257,9 +262,14 @@ def test_zero_collinear(self):
                 tvals1 = res1.tvalues[keep_index_p]
             assert_allclose(tvals1, res2.tvalues, rtol=5e-8)
 
-            with pytest.warns(RuntimeWarning, match="invalid value"):
-                # passing NaNs into scipy.stats functions
+            # See gh5993
+            if PLATFORM_LINUX32:
                 pvals1 = res1.pvalues[keep_index_p]
+            else:
+                with pytest.warns(RuntimeWarning,
+                                  match="invalid value encountered"):
+                    # passing NaN into scipy.stats functions
+                    pvals1 = res1.pvalues[keep_index_p]
             assert_allclose(pvals1, res2.pvalues, rtol=1e-6, atol=1e-30)
 
             if hasattr(res1, 'resid'):