Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Help: Multiple constraints for clogit

    Hi,

    I was wondering if someone could help with defining multiple constraint using clogit. I have Stata version 14 & 15. The following works:

    constraint 1 logprice = 1.132817
    clogit target logprice norm_probs, group(raceid) constraint(1)

    However, what I will like to do is define a constraint for the coefficient of logprice & norm_probs.

    What I have done so far is:

    . constraint 1 logprice = 1.132817

    . constraint 2 norm_probs = 1.425557

    clogit target logprice norm_probs, group(raceid) constraints(1 2)

    I kept getting the following err0r message :'
    redundant or inconsistent constraints
    r(412);'

    Any help will be highly appreciated!

    Thanks,
    Larry





  • #2
    Welcome to Statalist. Before posting again, please take a few minutes to read the Forum FAQ (black bar at top of page) and note, for example, recommendations about to post effectively, and also to use CODE delimiters for reporting exactly what you typed into Stata and exactly what you got back.

    We don't know, for instance, about the output you got with "constraint(1)" imposed. It might show us that "norm_probs" does not vary over time for each raceid observation and hence its coefficient is not identified using a clogit estimator. This sort of information is relevant for assessing whether the error is due to a "redundant" or to an "inconsistent" constraint.

    BTW tip for the future: you can look at more detailed ouput from error 412
    Code:
    . error 412
    redundant or inconsistent constraints
    r(412);
    and then click on the blue "r(412)", getting

    Code:
    [P]     error . . . . . . . . . . . . . . . . . . . . . . . .  Return code 412
            redundant or inconsistent constraints
            For instance, you are estimating a constrained model with
            mlogit.  Among the constraints specified is at least one
            that is redundant or inconsistent.  A redundant constraint
            might constrain a coefficient to be zero that some other
            constraint also constrains to be zero.  An inconsistent
            constraint might constrain a coefficient to be 1 that
            some other constraint constrains to be zero.  List the
            constraints, find the offender, and then reissue the mlogit
            command omitting it.
    
    (end of search)
    That's not particularly helpful. However, reviewing the examples in help constraint suggests there might be an issue with how you specified the 2 constraints. I was wondering whether
    Code:
    constraints(1 2)
    was a valid way to specify things, i.e. is "1 2" a valid numlist. However, inspection of the Base manual entry for constraints and numlist suggests that is ok.

    So, I'm left with my original question about how/whether your variables vary over time

    Comment


    • #3
      Thanks alot Stephen for the guardian. Please see below when I specify constraint 1

      Click image for larger version

Name:	Capture.PNG
Views:	1
Size:	15.8 KB
ID:	1535876


      When I specify two constraints, that is where the issue lies:
      Click image for larger version

Name:	Capture.PNG
Views:	1
Size:	5.4 KB
ID:	1535877




      Comment


      • #4
        Erm, you can't constrain the coefficient on logprice to be both 1.132817 and 1.425557! No wonder Stata told you there was an inconsistency. Show us the results of ...
        Code:
        constraint 1 logprice = 1.132817
        
        constraint 2 norm_probs = 1.425557
        
        clogit target logprice norm_probs, group(raceid) constraints(1 2)
        and please do so using CODE delimiters (as per FAQ), not using the copy/paste method you used. (It would be a weird model in practice though. Why constrain the coefficients on all the regressors? Are there other regressors that you've not told us about?)

        Whatever, now you should understand the value of the FAQ advice: showing us everything and exactly what you typed into Stata and all and exactly what you got back.

        Comment


        • #5
          The reason for constraining both variables was to check if the McFadden of the model below outperforms another method.

          Code:
          . constraint 1 logprice = 1.132817
          
          . constraint 2 norm_probs = 1.425557
          
          . clogit target logprice norm_probs , group(raceid) constraints(1 2)
          
          redundant or inconsistent constraints
          r(412);
          
          .

          Comment


          • #6
            Is your error message a consequence of not having any other covariates in your regression? I wonder if it possible to fix all the identifiable parameters at particular values and yet still have a clogit model that can be fitted. (Crudely speaking, I'm thinking that you want to fit a model with a constant only -- the doubly constrained one -- and that's not identifiable. So, Stata complains.) What do you get if you run the same (doubly constrained) regression but also including a covariate that has some variation over time for raceid obs?

            Comment


            • #7
              You are right Steve. When I add additional co-variate, the constraints work-

              Code:
              . 
              . constraint 1 logprice = 1.132817
              
              . constraint 2 norm_probs = 1.425557
              
              . clogit target logprice norm_probs weight , group(raceid) constraints(1 2)
              
              Iteration 0:   log likelihood = -17682.263  
              Iteration 1:   log likelihood = -17680.691  
              Iteration 2:   log likelihood = -17680.691  
              
              Conditional (fixed-effects) logistic regression
              
                                                              Number of obs     =     92,137
                                                              Wald chi2(1)      =       9.10
              Log likelihood = -17680.691                     Prob > chi2       =     0.0026
              
               ( 1)  [target]logprice = 1.132817
               ( 2)  [target]norm_probs = 1.425557
              ------------------------------------------------------------------------------
                    target |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
              -------------+----------------------------------------------------------------
                  logprice |   1.132817  (constrained)
                norm_probs |   1.425557  (constrained)
                    weight |  -.0071046   .0023555    -3.02   0.003    -.0117213   -.0024878
              ------------------------------------------------------------------------------

              Comment


              • #8
                That should still work, even with constraints on all the parameters. What will happen in that case is that the likelihood will be evaluated at the given values:

                Code:
                . webuse lowbirth2, clear
                (Applied Logistic Regression, Hosmer & Lemeshow)
                
                . constraint 1 lwt   = -0.01
                
                . constraint 2 smoke =  1.00
                
                . clogit low lwt smoke, group(pairid) constraints(1 2)
                
                
                Conditional (fixed-effects) logistic regression
                
                                                                Number of obs     =        112
                                                                Wald chi2(0)      =          .
                Log likelihood =  -34.24468                     Prob > chi2       =          .
                
                 ( 1)  [low]lwt = -.01
                 ( 2)  [low]smoke = 1
                ------------------------------------------------------------------------------
                         low |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
                -------------+----------------------------------------------------------------
                         lwt |       -.01  (constrained)
                       smoke |          1  (constrained)
                ------------------------------------------------------------------------------
                Perhaps make sure that your Stata is up-to-date. Open a fresh instance and enter

                Code:
                update query
                and follow the instructions on the screen.

                Joerg

                Comment


                • #9
                  Thanks Joerg. What version of Stata are you using? I'm still having similar error:
                  Code:
                  . webuse lowbirth2, clear
                  (Applied Logistic Regression, Hosmer & Lemeshow)
                  
                  .  constraint 1 lwt   = -0.01
                  
                  .  constraint 2 smoke =  1.00
                  
                  . clogit low lwt smoke, group(pairid) constraints(1 2)
                  
                  redundant or inconsistent constraints
                  r(412);
                  One other question- Is it still possible to get fitstats after constraining all the variables including McFadden/Pseudo R2?

                  Btw, I'm doing an update to see if this will make any difference. I am on 15.0

                  Thanks

                  Comment


                  • #10
                    My example runs fine in 15.1. If you are on 15.0, it means that your Stata version is not up-to-date. As I have mentioned in my previous post, please enter
                    Code:
                    update query
                    and follow the instructions on the screen to bring Stata up-to-date. I don't know what exactly fitstat can or cannot do (notice it's not an official command), but the formula for McFadden's pseudo R^2 is simple, you could just use display to calculate it. That said, I can't really see what reasonable comparison could be made here seeing that the model has no intercept(s) to begin with and no parameters are freely estimated. Perhaps clarify what your ultimate purpose is here, my suspicion is that you are somehow on the wrong track.

                    Joerg

                    Comment


                    • #11
                      Sorry for the late response Joerg. I've been able to install version 16.0 and the command works perfectly well. On the details of why? I am doing some tests which requires that I constraint some of the coefficients in the model but not necessarily all the independent variables. Thank you!

                      Comment

                      Working...
                      X