Repository: statsmodels/statsmodels

Issue:
enh: fractional Logit, Probit
http://onlinelibrary.wiley.com/doi/10.1002/%28SICI%291099-1255%28199611%2911:6%3C619::AID-JAE418%3E3.0.CO;2-1/abstract

we need to replace the check for set (0, 1) with interval [0, 1]

partial skimming of the paper only:

uses QuasiMLE with  Logit/Bernoulli and sandwich covariance for robust.
this means Logit with `cov_type="white"` or "H0"  should already do everything.

They have a 2008 paper that uses Probit. in panel setting
http://www.sciencedirect.com/science/article/pii/S030440760800050X

the first article has 1417 citations in Google so there is a lot more similar.



Discussion:
```
"
Interestingly, the robust standard errors from equation (9) in the context of ordinary logit
and probit are computed almost routinely by certain statistics and econometrics packages,
such as STATA@ and SST@. Unfortunately, the packages with which we are familiar
automatically transform the dependent variable used in logit or probit into a binary variable
before estimation, or do not allow non-binary variables at all (STATA@ and SST@ fall into
the first category). With the minor change of allowing for fractional y in so-called binary
response analysis, standard software packages could be used to estimate the parameters in
equation (4) and to perform asymptotically valid inference. Alternatively, programming the
estimator in a language such as GAUSS@, as we do for our application in Section 4, is fairly
straightforward.
"
```

Papke and Wooldridge 1996

GLM in Stata has been updated since then
http://www.stata.com/support/faqs/statistics/logit-transformation/

@kshedden   Does GEE work with fractional data in a logit or probit binary/binomial model?

I haven't looked at the example yet, it has panel data for a response variable that is a proportion

in the Papke Wooldrige 2008 article they use just GLM and GEE (among others)

for example

```
glm math4 lavgrexp alavgrexp lunch alunch lenroll alenroll y96-y01 if year>1994, fa(bin) link(probit) cluster(distid)
mat b = e(b)
xtgee math4 lavgrexp lunch lenroll alavgrexp alunch alenroll y96-y01, fa(bi) link(probit) corr(exch) robust from(b,skip)
```

Papke has the replication files on her (departmental) web page (her personal page gives me a permission error) http://www.econ.msu.edu/faculty/papke/

It seems to work fine, I made a notebook:

http://nbviewer.ipython.org/urls/umich.box.com/shared/static/y0azjuau3t21b7p11m56.ipynb

On Sat, Oct 11, 2014 at 9:19 AM, Josef Perktold notifications@github.com
wrote:

> @kshedden https://github.com/kshedden Does GEE work with fractional
> data in a logit or probit binary/binomial model?
> 
> I haven't looked at the example yet, it has panel data for a response
> variable that is a proportion
> 
> in the Papke Wooldrige 2008 article they use just GLM and GEE (among
> others)
> 
> for example
> 
> glm math4 lavgrexp alavgrexp lunch alunch lenroll alenroll y96-y01 if year>1994, fa(bin) link(probit) cluster(distid)
> mat b = e(b)
> xtgee math4 lavgrexp lunch lenroll alavgrexp alunch alenroll y96-y01, fa(bi) link(probit) corr(exch) robust from(b,skip)
> 
> Papke has the replication files on her (departmental) web page (her
> personal page gives me a permission error)
> http://www.econ.msu.edu/faculty/papke/
> 
> —
> Reply to this email directly or view it on GitHub
> https://github.com/statsmodels/statsmodels/issues/2040#issuecomment-58749283
> .

PR?


Resolving patch:
diff --git a/statsmodels/discrete/discrete_model.py b/statsmodels/discrete/discrete_model.py
--- a/statsmodels/discrete/discrete_model.py
+++ b/statsmodels/discrete/discrete_model.py
@@ -365,8 +365,8 @@ class BinaryModel(DiscreteModel):
     def __init__(self, endog, exog, **kwargs):
         super(BinaryModel, self).__init__(endog, exog, **kwargs)
         if (self.__class__.__name__ != 'MNLogit' and
-            not np.all(np.unique(self.endog) == [0, 1])):
-            raise ValueError("endog must contain 0s and 1s only.")
+                not np.all((self.endog >= 0) & (self.endog <= 1))):
+            raise ValueError("endog must be in the unit interval.")
 
 
     def predict(self, params, exog=None, linear=False):


Test patch: