Announcement

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

  • Conformability error r(503) when using RERI command

    Hello,

    I am trying to estimate interaction on an additive scale between two exposure variables, A and B. Exposure A is a 5-level categorigal variable measuring quintiles of neighbourhood deprivation, and exposure B is a 3-level categorical variable measuring individual-level socioeconomic status. I have therefore created dummy variables for each level of A and B (see code below). My outcome, Y, is a binary variable measuring smoking status. I have not included additional covariates in the model for now.

    I am using the new reri in Stata 18 to estimate additive interaction. I have no problem running binomial regression using binreg for all combinations of A and B, but when I add the reri option, I get the 503 conformability error for all but one combination of A and B. Is anyone familiar with reri? Any advice would be very much appreciated! Thank you very much!

    Code:
    //additive interaction using reri
    
    //create dummy variables for A (5-level variable with values 1-5)
    generate A2=0 if A==1 
    replace A2=1 if A==2
    
    generate A3=0 if A==1 
    replace A3=1 if A==3
    
    generate A4=0 if A==1 
    replace A4=1 if A==4
    
    generateA5=0 if A==1 
    replace A5=1 if A==5
    
    //create dummy variables for B (3-level variable with values 0-2)
    generate B2=0 if B==0 
    replace B2=1 if B==1
    
    generate B3=0 if B==0 
    replace B3=1 if B==2
    
    //multiplicative interaction
    binreg Y A2#B2, rr 
    binreg Y A2#B3, rr 
    
    binreg Y A3#B2, rr 
    ​​​​​​​binreg Y A3#B3, rr 
    
    ​​​​​​​binreg Y A4#B2, rr 
    ​​​​​​​binreg Y A4#B3, rr 
    
    ​​​​​​​binreg Y A5#B2, rr 
    ​​​​​​​binreg Y A5#B3, rr 
    
    //additive interaction
    reri binreg Y A2#B2, rr //error
    reri binreg Y A2#B3, rr //error
    
    reri ​​​​​​​binreg Y A3#B2, rr 
    reri ​​​​​​​binreg Y A3#B3, rr //error
    
    reri ​​​​​​​binreg Y A4#B2, rr //error
    reri ​​​​​​​binreg Y A4#B3, rr //error
    
    reri ​​​​​​​binreg Y A5#B2, rr //error
    reri ​​​​​​​binreg Y A5#B3, rr //error

  • #2
    Thank you for showing us your code, but without an example dataset it is hard for us to help you.

    Here is an example from the help file.

    Code:
    webuse nitrates
    reri binreg tube drug nitrate, rr
    Notice that drug and nitrate are not interacted. reri does the interaction of the first two binary predictor variables for you.

    I expect you to get a syntax error with your specifications. For example, here is what I get when I interact drug and nitrate when using the reri prefix.

    Code:
    . reri binreg tube drug#nitrate, rr
    too few variables specified
    r(102);
    When I try to reproduce your generated binary variables setup with a different dataset with categorical variables, I get the no observations error code (but not the message???, we try to will fix that soon) for the correct reri syntax and the above error message when I interact the generated binary indicator variables.

    Code:
    webuse nhanes2l
    generate a2=0 if agegrp == 1
    replace a2=1 if agegrp == 2
    generate b2=0 if hsizgp == 1
    replace b2=1 if hsizgp == 2
    reri binreg heartatk a2 b2, rr
    reri binreg heartatk a2#b2, rr
    Here is the reri output from the above two commands.

    Code:
    . reri binreg heartatk a2 b2, rr
    r(2000);
    
    . reri binreg heartatk a2#b2, rr
    too few variables specified
    r(102);
    If you can't share your data, via dataex, and cannot reproduce the problem with a simulated dataset, please share the Stata log that shows us what you typed and what Stata reported.

    Comment


    • #3
      Hi Jeff,

      Thank you so much for your reply. My mistake, when I copied my code into this forum I made a mistake that I did not make when actually running the code, hence the unnecessary interaction signs. Thanks for pointing that out.

      I am unable to completely reproduce the error in an example data set, especially since I don't know why the error is occuring, but I have created a random sample of 100 observations of my data where I do get the error for two of the models. The remaining models get collinearity errors. Just for info, my real data set is over 170,000 observations with some missing data, this random sample includes only complete observations.

      Thank you for your help!

      Code:
      //sample data of 100 observations
      
      clear
      input float(ID A B Y)
        2251 3 2 0
        2616 2 0 0
        2739 2 1 0
        8656 3 1 1
       11635 2 2 0
       12063 1 0 1
       14556 3 2 1
       17692 1 0 0
       22288 3 2 0
       23194 4 2 1
       26862 1 2 0
       27146 1 0 0
       29556 2 0 0
       32998 1 0 0
       35402 1 1 0
       35724 4 2 1
       37155 3 1 1
       37353 1 0 0
       40091 1 1 0
       40118 1 0 0
       44620 1 0 1
       46530 2 2 1
       48366 1 0 0
       48441 4 0 0
       50893 5 2 0
       50968 4 1 0
       50986 1 2 1
       53426 4 2 0
       53797 3 2 0
       55485 4 2 0
       56018 2 1 0
       56735 2 0 0
       59852 1 1 0
       60314 1 1 1
       63463 1 0 0
       63992 1 0 0
       66555 1 0 0
       67714 4 2 1
       70785 3 1 1
       71674 1 0 0
       72302 3 2 1
       72856 3 2 0
       73646 4 2 1
       73738 2 0 0
       75919 2 2 0
       76623 1 1 0
       77686 2 2 0
       78702 2 0 0
       79130 2 1 0
       79761 5 2 0
       82065 2 1 0
       83848 2 2 0
       84052 1 0 0
       86190 2 0 0
       89568 3 0 0
       93216 5 1 0
       96708 5 1 1
       96927 4 2 1
       99393 2 1 1
      104569 3 2 0
      104707 1 0 0
      109109 2 2 0
      110010 1 0 0
      111407 2 0 0
      113956 4 1 1
      114172 3 0 0
      116870 2 2 0
      118758 1 1 0
      126201 3 2 0
      128127 1 0 0
      128382 3 0 0
      129519 4 2 0
      130159 4 0 0
      130356 5 2 0
      132228 1 0 0
      138178 1 0 0
      140007 3 1 1
      140070 3 0 0
      140767 4 0 0
      142048 2 1 1
      143234 3 2 1
      143501 1 1 0
      145192 1 2 0
      150448 1 0 0
      153422 4 1 1
      156159 1 1 0
      158447 1 1 0
      160731 3 0 0
      161313 1 1 0
      161759 1 0 0
      163748 2 2 1
      163834 3 2 1
      167091 3 1 0
      167868 1 1 1
      168289 5 1 0
      168775 2 0 1
      170219 1 1 0
      171844 3 0 0
      171879 2 0 0
      178080 1 0 0
      end
      
      //create dummy variables for A (5-level variable with values 1-5)
      generate A2=0 if A==1 
      replace A2=1 if A==2
      
      generate A3=0 if A==1 
      replace A3=1 if A==3
      
      generate A4=0 if A==1 
      replace A4=1 if A==4
      
      generate A5=0 if A==1 
      replace A5=1 if A==5
      
      //create dummy variables for B (3-level variable with values 0-2)
      generate B2=0 if B==0 
      replace B2=1 if B==1
      
      generate B3=0 if B==0 
      replace B3=1 if B==2
      
      //additive interaction
      reri binreg Y A2 B2, rr //error 503 - conformability
      reri binreg Y A2 B3, rr //error 503 - conformability
      
      reri binreg Y A3 B2, rr //error 459 - collinearity or empty cell
      reri binreg Y A3 B3, rr //error 459 - collinearity or empty cell
      
      reri binreg Y A4 B2, rr //error 459 - collinearity or empty cell
      reri binreg Y A4 B3, rr //error 459 - collinearity or empty cell
      
      reri binreg Y A5 B2, rr //error 459 - collinearity or empty cell
      reri binreg Y A5 B3, rr //error 459 - A5 has only one value in estimation sample of 24 observations

      Comment


      • #4

        Thank you for the data, that helped me find the source of the problem.

        The conformability error you are getting is due to a bug in reri.
        This bug is triggered when there is a missing value in the first
        observation of either of the binary predictor variables. We hope to
        have this fixed in a future update to Stata 18.

        The other error messages are legitimate. To get a better sense of the
        problem reri has with your model and data, try running the
        underlying model without the reri prefix. For example, the
        following shows that reri exits with an error complaining about a
        problem with an element of the interaction of the binary variables. The
        output from fitting the underlying model tells us that this element
        prefectly predicts an outcome, meaning its effect is absolute (i.e.
        infinte) and thus those observations must be removed in order to fit the
        model for the remaining data (this also causes an empty cell in the
        interaction). reri will only produce a table of results if the
        interaction of the binary variables is fully estimable -- in this case
        it is not.

        Code:
        . reri binreg Y A3 B2, rr //error 459 - collinearity or empty cell
        
        Fitting binreg ...
        interaction 1.A3#0b.B2 omitted due to collinearity or empty cell
        r(459);
        
        . binreg Y A3#B2, rr
        note: 1.A3#0.B2 != 0 predicts failure perfectly;
              1.A3#0.B2 omitted and 6 obs not used.
        
        
        Iteration 1:  Deviance =  262.2823
        Iteration 2:  Deviance =  251.0156
        Iteration 3:  Deviance =  250.1016
        Iteration 4:  Deviance =  250.0744
        Iteration 5:  Deviance =  250.0743
        Iteration 6:  Deviance =  250.0743
        
        Generalized linear models                         Number of obs   =         44
        Optimization     : MQL Fisher scoring             Residual df     =         41
                           (IRLS EIM)                     Scale parameter =          1
        Deviance         =  250.0743346                   (1/df) Deviance =   6.099374
        Pearson          =    600000029                   (1/df) Pearson  =   1.46e+07
        
        Variance function: V(u) = u*(1-u)                 [Bernoulli]
        Link function    : g(u) = ln(u)                   [Log]
        
                                                          BIC             =   94.92256
        
        ------------------------------------------------------------------------------
                     |                 EIM
                   Y | Risk ratio   std. err.      z    P>|z|     [95% conf. interval]
        -------------+----------------------------------------------------------------
               A3#B2 |
                0 1  |       1.75   1.631393     0.60   0.548     .2815315      10.878
                1 0  |          1  (empty)
                1 1  |        8.4   5.953796     3.00   0.003     2.093921    33.69755
                     |
               _cons |   .0952381   .0640561    -3.50   0.000      .025486    .3558933
        ------------------------------------------------------------------------------
        Note: _cons estimates baseline risk.

        Comment


        • #5
          Hi Jeff,
          Thank you very much for your help. Your explanation is very clear. I look forward to the bug being fixed in a future update, in the mean time I'll calculate the additive interaction by hand.
          Best,
          Kate

          Comment


          • #6
            The fix to reri is now live, as of Stata 18 update on 20dec2023.

            Comment


            • #7
              Dear Jeff/All,

              I am also struggling with a conformability error with the RERI command, despite updating to the latest version of Stata 18.

              Code:
              * Example generated by -dataex-. For more info, type help dataex
              clear
              input double(n Age_band A2 A3) byte Ethnicity double(E2 E3 E4 outcome)
                1 3 . 1 1 0 0 0 0
                2 2 1 . 1 0 0 0 0
                3 3 . 1 1 0 0 0 0
                4 2 1 . 1 0 0 0 0
                5 2 1 . 1 0 0 0 0
                6 3 . 1 1 0 0 0 0
                7 3 . 1 1 0 0 0 0
                8 2 1 . 4 . . 1 0
                9 2 1 . 1 0 0 0 1
               10 2 1 . 1 0 0 0 0
               11 2 1 . 1 0 0 0 0
               12 3 . 1 1 0 0 0 0
               13 1 0 0 3 . 1 . 0
               14 3 . 1 1 0 0 0 0
               15 2 1 . 1 0 0 0 0
               16 2 1 . 1 0 0 0 0
               17 1 0 0 1 0 0 0 0
               18 2 1 . 1 0 0 0 0
               19 3 . 1 1 0 0 0 0
               20 2 1 . 1 0 0 0 0
               21 2 1 . 1 0 0 0 0
               22 2 1 . 1 0 0 0 0
               23 2 1 . 1 0 0 0 0
               24 2 1 . 1 0 0 0 0
               25 3 . 1 1 0 0 0 0
               26 3 . 1 1 0 0 0 0
               27 3 . 1 1 0 0 0 0
               28 1 0 0 1 0 0 0 0
               29 3 . 1 1 0 0 0 0
               30 2 1 . 1 0 0 0 0
               31 3 . 1 1 0 0 0 0
               32 2 1 . 1 0 0 0 0
               33 1 0 0 1 0 0 0 0
               34 3 . 1 1 0 0 0 0
               35 3 . 1 2 1 . . 1
               36 1 0 0 1 0 0 0 0
               37 3 . 1 1 0 0 0 0
               38 3 . 1 1 0 0 0 0
               39 1 0 0 1 0 0 0 0
               40 3 . 1 1 0 0 0 0
               41 2 1 . 1 0 0 0 0
               42 1 0 0 3 . 1 . 0
               43 2 1 . 1 0 0 0 0
               44 3 . 1 1 0 0 0 0
               45 2 1 . 4 . . 1 0
               46 2 1 . 1 0 0 0 0
               47 2 1 . 1 0 0 0 0
               48 2 1 . 1 0 0 0 0
               49 3 . 1 1 0 0 0 1
               50 3 . 1 1 0 0 0 0
               51 2 1 . 4 . . 1 1
               52 2 1 . 2 1 . . 1
               53 1 0 0 4 . . 1 0
               54 2 1 . 1 0 0 0 0
               55 3 . 1 3 . 1 . 0
               56 3 . 1 1 0 0 0 1
               57 3 . 1 1 0 0 0 0
               58 2 1 . 1 0 0 0 0
               59 2 1 . 1 0 0 0 0
               60 1 0 0 2 1 . . 0
               61 2 1 . 1 0 0 0 0
               62 3 . 1 1 0 0 0 0
               63 1 0 0 1 0 0 0 0
               64 2 1 . 2 1 . . 0
               65 2 1 . 1 0 0 0 0
               66 1 0 0 1 0 0 0 0
               67 3 . 1 1 0 0 0 0
               68 3 . 1 1 0 0 0 0
               69 2 1 . 2 1 . . 0
               70 3 . 1 1 0 0 0 0
               71 1 0 0 1 0 0 0 0
               72 2 1 . 1 0 0 0 1
               73 2 1 . 2 1 . . 0
               74 3 . 1 1 0 0 0 0
               75 2 1 . 1 0 0 0 0
               76 3 . 1 1 0 0 0 0
               77 3 . 1 1 0 0 0 0
               78 3 . 1 1 0 0 0 0
               79 1 0 0 2 1 . . 0
               80 3 . 1 1 0 0 0 1
               81 3 . 1 1 0 0 0 0
               82 2 1 . 1 0 0 0 0
               83 3 . 1 2 1 . . 0
               84 3 . 1 1 0 0 0 0
               85 3 . 1 1 0 0 0 0
               86 2 1 . 1 0 0 0 0
               87 1 0 0 1 0 0 0 0
               88 2 1 . 1 0 0 0 0
               89 2 1 . 1 0 0 0 0
               90 3 . 1 1 0 0 0 1
               91 3 . 1 1 0 0 0 0
               92 2 1 . 4 . . 1 0
               93 3 . 1 1 0 0 0 0
               94 2 1 . 1 0 0 0 0
               95 2 1 . 1 0 0 0 0
               96 2 1 . 1 0 0 0 0
               97 3 . 1 1 0 0 0 0
               98 3 . 1 1 0 0 0 0
               99 2 1 . 1 0 0 0 0
              100 2 1 . 1 0 0 0 0
              end
              label def Age_band 1 "<40", modify
              label def Age_band 2 "40-65", modify
              label def Age_band 3 ">65", modify
              label def Ethnicity 1 "White", modify
              label def Ethnicity 2 "Black", modify
              label def Ethnicity 3 "Asian", modify
              label def Ethnicity 4 "Mixed/Other", modify
              label def outcome 0 "No drug initiated", modify
              label def outcome 1 "Drug initiated", modify
              
              gen A2=0 if Age_band==1
              replace A2=1 if Age_band==2
              
              gen A3=0 if Age_band==1
              replace A3=1 if Age_band==3
              
              gen E2=0 if Ethnicity==1
              replace E2=1 if Ethnicity==2
              
              gen E3=0 if Ethnicity==1
              replace E3=1 if Ethnicity==3
              
              gen E4=0 if Ethnicity==1
              replace E4=1 if Ethnicity==4

              Code:
              reri poisson outcome A2 E3
              
              Fitting poisson ...
              
              Interaction of A2 and E3 on an additive scale
              
              Model: Poisson                                  Number of observations = 3,377
              
                     A2#E3
                      - +    0 1
                      + -    1 0
                      + +    1 1
              
              ------------------------------------------------------------------------------
                           |               Robust
                           |        ERR   std. err.      z    P>|z|     [95% conf. interval]
              -------------+----------------------------------------------------------------
                     A2#E3 |
                      - +  |          .          .        .       .            .           .
              conformability error
              r(503);
              Whereas it seems to work ok for other levels of the variables:

              Code:
              . reri poisson outcome A3 E2
              
              Fitting poisson ...
              
              Interaction of A3 and E2 on an additive scale
              
              Model: Poisson                                  Number of observations = 2,814
              
                     A3#E2
                      - +    0 1
                      + -    1 0
                      + +    1 1
              
              ------------------------------------------------------------------------------
                           |               Robust
                           |        ERR   std. err.      z    P>|z|     [95% conf. interval]
              -------------+----------------------------------------------------------------
                     A3#E2 |
                      - +  |   .7635601   .5371481     1.86   0.063    -.0291998    2.203691
                      + -  |  -.6391482    .049558    -7.42   0.000    -.7243055   -.5276873
                      + +  |  -.1924439   .3879773    -0.44   0.656    -.6850608    1.070707
              -------------+----------------------------------------------------------------
                      RERI |  -.3168558   .6462803    -0.49   0.624    -1.583542    .9498304
               Attr. prop. |  -.3923638   .9134194    -0.43   0.668    -2.182633    1.397905
              Synergy ind. |   -1.54683          .        .       .            .           .
              ------------------------------------------------------------------------------
              Notes: P>|z| for synergy index (SI) is for test H0: SI = 1.
                     Some estimates of excess relative risk are not positive.
              Any help would be much appreciated!

              Thanks,
              Mark

              Comment


              • #8
                Your data example does not reproduce the output you show.

                Given the output from your first call to reri, I suspect your Stata does not have the update I reference in #6. Run update query to check for the latest Stata update.

                Here is the output I get when running the above (ignoring the calls to generate since the A and E variables already exist from the dataex listing).
                Code:
                . reri poisson outcome A2 E3
                
                Fitting poisson ...
                interaction 1.A2#1.E3 omitted due to collinearity or empty cell
                r(459);
                The error message explains the exact problem with the dataset. Here is a tabulation that shows where the empty cell is:
                Code:
                . tabulate A2 E3
                
                           |          E3
                        A2 |         0          1 |     Total
                -----------+----------------------+----------
                         0 |         9          2 |        11 
                         1 |        37          0 |        37 
                -----------+----------------------+----------
                     Total |        46          2 |        48
                If after updating your Stata you still get the conformability error, please provide us with a dataset that reproduces the error.

                Comment

                Working...
                X