Repository: statsmodels/statsmodels

Issue:
DOC/TST/Review: binomial with non-canonical link 
https://github.com/statsmodels/statsmodels/issues/4597#issuecomment-386881123


`test_glm.py` has a comment, which I don't know what it means, or what's the reason for the comment
```
#TODO:
#Non-Canonical Links for the Binomial family require the algorithm to be
#slightly changed
```

I never looked at this case, i.e. Binomial count model with n_trials != 1, not Bernoulli.

The link function for the binomial probability can be anything. 
The question is whether the current code uses some computation that assumes canonical link, i.e. logit.
The only source could be in the aggregation for n_trials which is the only difference to other families in the implementation.

e.g. related: log-binomial is an example that we looked at, but only with respect to params and possible problems with support violations. ( #2208, #2215)

There might be nothing wrong in this case, but it needs checking.





Discussion:

Resolving patch:
diff --git a/statsmodels/base/model.py b/statsmodels/base/model.py
--- a/statsmodels/base/model.py
+++ b/statsmodels/base/model.py
@@ -1377,6 +1377,9 @@ def t_test(self, r_matrix, cov_p=None, scale=None, use_t=None):
             An alternative estimate for the parameter covariance matrix.
             If None is given, self.normalized_cov_params is used.
         scale : float, optional
+
+            .. deprecated:: 0.10.0
+
             An optional `scale` to use.  Default is the scale specified
             by the model fit.
         use_t : bool, optional
@@ -1449,6 +1452,12 @@ def t_test(self, r_matrix, cov_p=None, scale=None, use_t=None):
         f_test : for F tests
         patsy.DesignInfo.linear_constraint
         """
+        if scale is not None:
+            import warnings
+            warnings.warn('scale is has no effect and is deprecated. It will'
+                          'be removed in the next version.',
+                          DeprecationWarning)
+
         from patsy import DesignInfo
         names = self.model.data.param_names
         LC = DesignInfo(names).linear_constraint(r_matrix)
@@ -1520,6 +1529,9 @@ def f_test(self, r_matrix, cov_p=None, scale=1.0, invcov=None):
             An alternative estimate for the parameter covariance matrix.
             If None is given, self.normalized_cov_params is used.
         scale : float, optional
+
+            .. deprecated:: 0.10.0
+
             Default is 1.0 for no scaling.
         invcov : array-like, optional
             A q x q array to specify an inverse covariance matrix based on a
@@ -1591,8 +1603,13 @@ def f_test(self, r_matrix, cov_p=None, scale=1.0, invcov=None):
         design matrix of the model. There can be problems in non-OLS models
         where the rank of the covariance of the noise is not full.
         """
-        res = self.wald_test(r_matrix, cov_p=cov_p, scale=scale,
-                             invcov=invcov, use_f=True)
+        if scale != 1.0:
+            import warnings
+            warnings.warn('scale is has no effect and is deprecated. It will'
+                          'be removed in the next version.',
+                          DeprecationWarning)
+
+        res = self.wald_test(r_matrix, cov_p=cov_p, invcov=invcov, use_f=True)
         return res
 
     # TODO: untested for GLMs?
@@ -1615,6 +1632,9 @@ def wald_test(self, r_matrix, cov_p=None, scale=1.0, invcov=None,
             An alternative estimate for the parameter covariance matrix.
             If None is given, self.normalized_cov_params is used.
         scale : float, optional
+
+            .. deprecated:: 0.10.0
+
             Default is 1.0 for no scaling.
         invcov : array-like, optional
             A q x q array to specify an inverse covariance matrix based on a
@@ -1648,6 +1668,12 @@ def wald_test(self, r_matrix, cov_p=None, scale=1.0, invcov=None,
         design matrix of the model. There can be problems in non-OLS models
         where the rank of the covariance of the noise is not full.
         """
+        if scale != 1.0:
+            import warnings
+            warnings.warn('scale is has no effect and is deprecated. It will'
+                          'be removed in the next version.',
+                          DeprecationWarning)
+
         if use_f is None:
             # switch to use_t false if undefined
             use_f = (hasattr(self, 'use_t') and self.use_t)
diff --git a/statsmodels/regression/mixed_linear_model.py b/statsmodels/regression/mixed_linear_model.py
--- a/statsmodels/regression/mixed_linear_model.py
+++ b/statsmodels/regression/mixed_linear_model.py
@@ -2471,6 +2471,11 @@ def t_test(self, r_matrix, scale=None, use_t=None):
             The available results have the same elements as the parameter table
             in `summary()`.
         """
+        if scale is not None:
+            import warnings
+            warnings.warn('scale is has no effect and is deprecated. It will'
+                          'be removed in the next version.',
+                          DeprecationWarning)
 
         if r_matrix.shape[1] != self.k_fe:
             raise ValueError("r_matrix for t-test should have %d columns"
@@ -2479,8 +2484,7 @@ def t_test(self, r_matrix, scale=None, use_t=None):
         d = self.k_re2 + self.k_vc
         z0 = np.zeros((r_matrix.shape[0], d))
         r_matrix = np.concatenate((r_matrix, z0), axis=1)
-        tst_rslt = super(MixedLMResults, self).t_test(
-            r_matrix, scale=scale, use_t=use_t)
+        tst_rslt = super(MixedLMResults, self).t_test(r_matrix, use_t=use_t)
         return tst_rslt
 
     def summary(self, yname=None, xname_fe=None, xname_re=None,


Test patch: