Skip to content

BUG? Should OrdinalGEE have no constant? #7068

Open

Description

@josef-pkt

I'm getting an overparameterized model when I use a constant in OrdinalGEE with independence and naive cov_type.

If I remove the constant, I get identical results to Ordered model with Logit in #7035 (except for incremental exp parameterization)

Activity

  1. josef-pkt commented on Sep 29, 2020

    @josef-pkt
    MemberAuthor
  2. josef-pkt commented on Sep 29, 2020

    @josef-pkt
    MemberAuthor

    data is anes96 merged to 3 categories

    from statsmodels.genmod.generalized_estimating_equations import OrdinalGEE
    
    groups = np.arange(len(en2)) // 20
    res_gee = OrdinalGEE(en2, exog.iloc[:, :-1], groups).fit(cov_type="naive")
    print(res_gee.summary())
                               OrdinalGEE Regression Results                           
    ===================================================================================
    Dep. Variable:                         PID   No. Observations:                 1888
    Model:                          OrdinalGEE   No. clusters:                       48
    Method:                        Generalized   Min. cluster size:                   8
                          Estimating Equations   Max. cluster size:                  40
    Family:                           Binomial   Mean cluster size:                39.3
    Dependence structure:  OrdinalIndependence   Num. iterations:                     7
    Date:                     Tue, 29 Sep 2020   Scale:                           1.000
    Covariance type:                     naive   Time:                         15:49:02
    ==============================================================================
                     coef    std err          z      P>|z|      [0.025      0.975]
    ------------------------------------------------------------------------------
    I(y>0.0)      -5.0308      0.440    -11.446      0.000      -5.892      -4.169
    I(y>1.0)      -6.5799      0.465    -14.164      0.000      -7.490      -5.669
    logpopul      -0.0792      0.022     -3.679      0.000      -0.121      -0.037
    selfLR         0.9908      0.059     16.813      0.000       0.875       1.106
    age           -0.0035      0.004     -0.834      0.404      -0.012       0.005
    educ           0.1552      0.047      3.335      0.001       0.064       0.246
    income         0.0610      0.013      4.834      0.000       0.036       0.086
    ==============================================================================
    Skew:                          0.0669   Kurtosis:                      -0.3029
    Centered skew:                 0.0699   Centered kurtosis:             -0.2646
    ==============================================================================
    b
    print(res_omb.summary())
                                 OrderedModel Results                             
    ==============================================================================
    Dep. Variable:                    PID   Log-Likelihood:                -802.55
    Model:                   OrderedModel   AIC:                             1619.
    Method:            Maximum Likelihood   BIC:                             1653.
    Date:                Tue, 29 Sep 2020                                         
    Time:                        15:47:25                                         
    No. Observations:                 944                                         
    Df Residuals:                     937                                         
    Df Model:                           7                                         
    ==============================================================================
                     coef    std err          z      P>|z|      [0.025      0.975]
    ------------------------------------------------------------------------------
    logpopul      -0.0792      0.022     -3.682      0.000      -0.121      -0.037
    selfLR         0.9908      0.059     16.739      0.000       0.875       1.107
    age           -0.0035      0.004     -0.830      0.407      -0.012       0.005
    educ           0.1552      0.046      3.375      0.001       0.065       0.245
    income         0.0610      0.013      4.865      0.000       0.036       0.086
    0/1            5.0308      0.438     11.477      0.000       4.172       5.890
    1/2            0.4377      0.060      7.323      0.000       0.321       0.555
    ==============================================================================
    

    with constant I get

    print(res_gee.summary())
                               OrdinalGEE Regression Results                           
    ===================================================================================
    Dep. Variable:                         PID   No. Observations:                 1888
    Model:                          OrdinalGEE   No. clusters:                       48
    Method:                        Generalized   Min. cluster size:                   8
                          Estimating Equations   Max. cluster size:                  40
    Family:                           Binomial   Mean cluster size:                39.3
    Dependence structure:  OrdinalIndependence   Num. iterations:                     7
    Date:                     Tue, 29 Sep 2020   Scale:                           1.000
    Covariance type:                     naive   Time:                         15:56:22
    ==============================================================================
                     coef    std err          z      P>|z|      [0.025      0.975]
    ------------------------------------------------------------------------------
    I(y>0.0)      -1.1605        nan        nan        nan         nan         nan
    I(y>1.0)      -2.7096        nan        nan        nan         nan         nan
    logpopul      -0.0792      0.022     -3.679      0.000      -0.121      -0.037
    selfLR         0.9908      0.059     16.813      0.000       0.875       1.106
    age           -0.0035      0.004     -0.834      0.404      -0.012       0.005
    educ           0.1552      0.047      3.335      0.001       0.064       0.246
    income         0.0610      0.013      4.834      0.000       0.036       0.086
    const         -3.8703        nan        nan        nan         nan         nan
    ==============================================================================
    Skew:                          0.0669   Kurtosis:                      -0.3029
    Centered skew:                 0.0699   Centered kurtosis:             -0.2646
    ==============================================================================
    ...\statsmodels_py37\statsmodels\statsmodels\genmod\generalized_estimating_equations.py:1783: RuntimeWarning: invalid value encountered in sqrt
      return np.sqrt(np.diag(self.cov_naive))
    
  3. josef-pkt commented on Sep 29, 2020

    @josef-pkt
    MemberAuthor

    unit tests TestGEEOrdinalCovType leave out constant

    endog, exog, groups = load_data("gee_ordinal_1.csv",
                                            icept=False)
    
  4. kshedden commented on Sep 29, 2020

    @kshedden
    Contributor

    That's right. The intercept would not be identified. It's similar to proportional hazards regression, where we have some code to detect and warn:

    I'm not sure if there is a better way to do this. We could use the same technique here in OrdinalGEE.

  5. josef-pkt commented on Sep 29, 2020

    @josef-pkt
    MemberAuthor

    The OrdinalGEE docstring doesn't mention this.

    I used the pattern from PHReg in OrderedModel #7035 but raise an exception if there is a constant left after preprocessing..
    The 0-1 warning in formula had too many false alarms in my test cases.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions