Announcement

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

  • How to compare two coefficients in two forthlogit regressions?

    Hello,

    As my dependent variable is a rare event, I am running forthlogit regressions. In my sample, I have three groups, g1, g2, g3, and I classify g1 and g2 as GROUP A and classify g2 and g3 as GROUP B. My regressions are as follows:
    firthlogit y x if GROUP A==1;
    firthlogit y x if GROUP B==1.
    I need to compare the coefficients on x in the two regressions. Suest doesn't work. Also I cannot use the full interaction like firthlogit y x GROUPB xGROUPB, because there is overlap between GROUP A and GROUP B. Any suggestion on how to compare the two coefficients on x in the two firthlogit regressions would be great helpful to me.

    Many Thanks in Advance!

  • #2
    I can show you the mechanics of the test below (begin at the "Begin here" comment), but you've got a conceptual issue that you'll need to work out on your own.

    .ÿ
    .ÿversionÿ15.1

    .ÿ
    .ÿclearÿ*

    .ÿ
    .ÿsetÿseedÿ`=strreverse("1493411")'

    .ÿquietlyÿsetÿobsÿ270

    .ÿ
    .ÿgenerateÿbyteÿyÿ=ÿruniform()ÿ>ÿ0.5

    .ÿgenerateÿbyteÿgÿ=ÿmod(_n,ÿ3)ÿ+ÿ1

    .ÿgenerateÿdoubleÿxÿ=ÿruniform()ÿ-ÿ0.5

    .ÿ
    .ÿgenerateÿbyteÿGROUP_Aÿ=ÿinlist(g,ÿ1,ÿ2)

    .ÿgenerateÿbyteÿGROUP_Bÿ=ÿinlist(g,ÿ2,ÿ3)

    .ÿ
    .ÿ*
    .ÿ*ÿBeginÿhere
    .ÿ*
    .ÿ//ÿIMPORTANT!ÿBeÿespeciallyÿsureÿtoÿdoÿtheÿnextÿtwoÿlinesÿofÿcode!
    .ÿdropÿGROUP_A

    .ÿdropÿGROUP_B

    .ÿ
    .ÿ//ÿNow,ÿtoÿtestÿwhetherÿx(gÿ=ÿ1ÿ|ÿ2)ÿisÿdifferentÿfromÿx(gÿ=ÿ2ÿ|ÿ3)
    .ÿlogitÿyÿi.g##c.x,ÿnolog

    LogisticÿregressionÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿNumberÿofÿobsÿÿÿÿÿ=ÿÿÿÿÿÿÿÿ270
    ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿLRÿchi2(5)ÿÿÿÿÿÿÿÿ=ÿÿÿÿÿÿÿ3.45
    ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿProbÿ>ÿchi2ÿÿÿÿÿÿÿ=ÿÿÿÿÿ0.6316
    Logÿlikelihoodÿ=ÿ-184.35869ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿPseudoÿR2ÿÿÿÿÿÿÿÿÿ=ÿÿÿÿÿ0.0093

    ------------------------------------------------------------------------------
    ÿÿÿÿÿÿÿÿÿÿÿyÿ|ÿÿÿÿÿÿCoef.ÿÿÿStd.ÿErr.ÿÿÿÿÿÿzÿÿÿÿP>|z|ÿÿÿÿÿ[95%ÿConf.ÿInterval]
    -------------+----------------------------------------------------------------
    ÿÿÿÿÿÿÿÿÿÿÿgÿ|
    ÿÿÿÿÿÿÿÿÿÿ2ÿÿ|ÿÿ-.0478481ÿÿÿ.3018073ÿÿÿÿ-0.16ÿÿÿ0.874ÿÿÿÿ-.6393795ÿÿÿÿ.5436834
    ÿÿÿÿÿÿÿÿÿÿ3ÿÿ|ÿÿ-.2285962ÿÿÿÿ.302644ÿÿÿÿ-0.76ÿÿÿ0.450ÿÿÿÿ-.8217676ÿÿÿÿ.3645752
    ÿÿÿÿÿÿÿÿÿÿÿÿÿ|
    ÿÿÿÿÿÿÿÿÿÿÿxÿ|ÿÿÿ1.196473ÿÿÿ.7228338ÿÿÿÿÿ1.66ÿÿÿ0.098ÿÿÿÿ-.2202549ÿÿÿÿ2.613202
    ÿÿÿÿÿÿÿÿÿÿÿÿÿ|
    ÿÿÿÿÿÿÿg#c.xÿ|
    ÿÿÿÿÿÿÿÿÿÿ2ÿÿ|ÿÿ-1.209489ÿÿÿ1.032927ÿÿÿÿ-1.17ÿÿÿ0.242ÿÿÿÿ-3.233988ÿÿÿÿ.8150105
    ÿÿÿÿÿÿÿÿÿÿ3ÿÿ|ÿÿ-1.178161ÿÿÿ1.031192ÿÿÿÿ-1.14ÿÿÿ0.253ÿÿÿÿÿ-3.19926ÿÿÿÿ.8429382
    ÿÿÿÿÿÿÿÿÿÿÿÿÿ|
    ÿÿÿÿÿÿÿ_consÿ|ÿÿ-.0852937ÿÿÿ.2143778ÿÿÿÿ-0.40ÿÿÿ0.691ÿÿÿÿ-.5054664ÿÿÿÿÿ.334879
    ------------------------------------------------------------------------------

    .ÿtestÿ3.g#x

    ÿ(ÿ1)ÿÿ[y]3.g#c.xÿ=ÿ0

    ÿÿÿÿÿÿÿÿÿÿÿchi2(ÿÿ1)ÿ=ÿÿÿÿ1.31
    ÿÿÿÿÿÿÿÿÿProbÿ>ÿchi2ÿ=ÿÿÿÿ0.2532

    .ÿ
    .ÿ//ÿor
    .ÿquietlyÿmarginsÿg,ÿdydx(x)ÿpredict(xb)ÿpost

    .ÿlocalÿGROUP_Aÿ_b[1.g]ÿ+ÿ_b[2.g]

    .ÿlocalÿGROUP_Bÿ_b[2.g]ÿ+ÿ_b[3.g]

    .ÿtestÿ`GROUP_A'ÿ=ÿ`GROUP_B'

    ÿ(ÿ1)ÿÿ[x]1bn.gÿ-ÿ[x]3.gÿ=ÿ0

    ÿÿÿÿÿÿÿÿÿÿÿchi2(ÿÿ1)ÿ=ÿÿÿÿ1.31
    ÿÿÿÿÿÿÿÿÿProbÿ>ÿchi2ÿ=ÿÿÿÿ0.2532

    .ÿ
    .ÿ//ÿToÿdoÿtheÿsameÿwithÿtheÿ(user-written—seeÿFAQ)ÿFirth-of-Forthÿlogitÿcommand:
    .ÿquietlyÿfirthlogitÿyÿi.g##c.x,ÿnolog

    .ÿestimatesÿstoreÿFull

    .ÿ
    .ÿconstraintÿdefineÿ1ÿ_b[3.g#x]ÿ=ÿ0

    .ÿquietlyÿfirthlogitÿyÿi.g##c.x,ÿconstraints(1)ÿnolog

    .ÿlrtestÿFull

    Likelihood-ratioÿtestÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿLRÿchi2(1)ÿÿ=ÿÿÿÿÿÿ1.28
    (Assumption:ÿ.ÿnestedÿinÿFull)ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿProbÿ>ÿchi2ÿ=ÿÿÿÿ0.2586

    .ÿ
    .ÿexit

    endÿofÿdo-file


    .

    Comment


    • #3
      Hi Joseph Coveney,

      Many Thanks for your suggestions! I got your point, but I forgot to clarify that the variable of interest x in my regression is g, that means my models are as follows:

      firthlogit y g x_control if g==1|2;
      firthlogit y g x_control if g==2|3,

      I need to compare the coefficients on g in the two regressions.

      Sorry again.

      Comment


      • #4
        Is the variable g ordered categorical?

        Comment


        • #5
          re: #3 - there is a typo in your "if" clauses: #|# will not do what you expect; Joseph showed a legitimate way to get what you want in #2; otherwise, you can use
          Code:
          if g==1 | g==2

          Comment


          • #6
            Hi Joseph, in my sample I have three types of contract designs (g1, g2, and g3). The variable g is categorical but not ordinal. Thank you!

            Comment


            • #7
              Thank you Rich for pointing out the typo!

              Comment

              Working...
              X