Announcement

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

  • Equavalent to the SAS ODDSRATIO command in stata 15 after XTGEE regression

    Using Stata 15, I am fitting a longitudinal GEE model with a binary main predictor and two binary candidate effect modifiers so that the model is parameterized with these three variables and two interaction terms crossing the main predictor with each of the candidate effect modifiers. I am interested in obtaining odds ratios and 95% confidence intervals for the main predictor at each of the four combinations of possible values for the two candidate effect modifiers. In SAS, the statistical software I use most, there is an ODDSRATIO statement that will calculate these results. For instance, it will report for “Predictor 1 vs 0 at modifier_1 = 1 and modifier_2 = 1” that the odds ratio is this and the 95% confidence intervals are that.



    How do I obtain such interaction term results for this model from Stata software when using the xtgee statement? I thank respondents in advance for any assistance they might provide.”


  • #2
    Hi Janet,

    Since you did not provide example data to demonstrate with, I used the Stata example dataset nlswork2.dta. Here is the relevant code:
    Code:
    webuse nlswork2
    xtset idcode year
    xtgee nev_mar i.collgrad#i.c_city i.collgrad#i.union , family(binomial) link(logit) corr(ind) eform base
    In this example, I used the binary variable 'collgrad' as the main predcitor, and 'c_city' and 'union' as two binary effect modifiers. I believe this will give you the odds ratios you are interested in. If not, please clarify and I am happy to help.

    Comment


    • #3
      Dear Matt,

      Thank you for your prompt response and the dataset example. Apologies I should have been more specific in my question. The model in which I am interested should include the main predictor and the two candidate effect modifiers as separate variables in addition to their occurrence in two interactions terms. Using your example here is the line of code that I think is relevant.
      [
      webuse nlswork2
      xtset idcode year
      xtgee nev_mar i.collgrad i._city i.union i.collgrad#i.c_city i.collgrad#i.union , family(binomial) link(logit) corr(ind) eform base]


      Given a model parameterized in this way, the SAS ODDSRATIO statement for the collgrad variable will yield four odds ratios and accompanying 95% confidence intervals—one when both modifiers are 0, one when they are both 1, one when the first is 1 and the second 0, and one when the first is 0 and the second 1.



      Is it possible to get these results by modification of the line of code we have provided? Thanks again for any assistance you can provide.

      Best wishes,
      Janet

      Comment


      • #4
        Hi Janet. Do the following -margins- commands give you the contrasts you want on the log-odds scale?

        Code:
        margins r.collgrad@c_city, predict(xb) contrast(nowald effects)
        margins r.collgrad@union, predict(xb) contrast(nowald effects)

        --
        Bruce Weaver
        Email: [email protected]
        Web: http://sites.google.com/a/lakeheadu.ca/bweaver/
        Version: Stata/MP 18.0 (Windows)

        Comment


        • #5
          Alternatively, you could use contrast with the eform option.

          Code:
          contrast r.collgrad@c_city#union, nowald effects eform
          Using your example in #3, I get this table of odds ratios:

          Code:
          . contrast r.collgrad@c_city#union, nowald effects eform
          
          Contrasts of marginal linear predictions
          
          Margins      : asbalanced
          
          ---------------------------------------------------------------------------------------
                                |     exp(b)   Std. Err.      z    P>|z|     [95% Conf. Interval]
          ----------------------+----------------------------------------------------------------
          collgrad@c_city#union |
                  (1 vs 0) 0 0  |   1.238503   .1287414     2.06   0.040     1.010218    1.518374
                  (1 vs 0) 0 1  |   1.058795     .16153     0.37   0.708       .78515    1.427813
                  (1 vs 0) 1 0  |   1.173535   .1336749     1.40   0.160     .9387229    1.467083
                  (1 vs 0) 1 1  |   1.003254   .1628026     0.02   0.984     .7299325    1.378921
          ---------------------------------------------------------------------------------------
          --
          Bruce Weaver
          Email: [email protected]
          Web: http://sites.google.com/a/lakeheadu.ca/bweaver/
          Version: Stata/MP 18.0 (Windows)

          Comment


          • #6
            Dear Bruce,

            Thank you very much!!! Apologies for the delay. The code works beautifully.

            Best wishes,
            Janet

            Comment

            Working...
            X