Announcement

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

  • Test if estimates are the same for 2 different groups

    Hi all,

    How can i run a test between 2 different groups within the sample?
    More specifically, i ran a regression on men and women - and now i want to see if the estimates are different from each other.

    I am using the following code to run the regressions i need.

    In total there are 10 regressions, (5 for men and 5 for women)

    Code:
    foreach x in 0 1 {
        preserve
        keep if female==`x'
        foreach d in 1 21 32 2 3 {
            reg d`d'lifesat treat $xvarsls $exact [weight=w_treat_xvarsls], robust
            outreg2 using analysis_ls, append excel dec(4)
            est store m`x'_1
            qui count if treat==1 & e(sample)
            estadd scalar obs =r(N)
            }
        restore
    }
    My goal is to to compare the estimates for each outcome variable.

    For example: Outcome = d1lifesat --> test if estimates are different between female==0 and female ==1
    The same for the 4 other outcomes (d21lifesat, d32lifesat, d2lifesat, d3lifesat)

    What is the easiest way to do so?

    Note: What i saw so far in stata is this...

    Code:
     Immediate form of two-sample t test
    
            ttesti #obs1 #mean1 #sd1 #obs2 #mean2 #sd2 [, options2]
    How can i apply this method or is there a different (better?) method?

    Thank you very much in advance

  • #2
    Konstantin:
    I think that the best way to do what you have in minf winthin an OLS framework is to interact -gender- with -treatment- and change your loop accordingly.
    Something like (assuming you have 2 treatment group):
    Code:
    regress d1lifesat i.treat##i.gender
    Kind regards,
    Carlo
    (Stata 19.0)

    Comment


    • #3
      Hi Carlo, thanks very much for that fast reply.

      I am not that familar with stata but i think that your approach doesnt work for me. I am applying a difference-in-difference matching estimation. In the matching step (and for the regression), i dont use interaction variables, espcially not with the treatment variable...i think that i cant regress the way you suggested.

      But maybe a different question regarding the ttesti command:

      how can i apply this? , or how can "manually" calculate standard deviations for the estimates to run the code?

      Comment


      • #4
        Hi Carlo, i tried what you suggested

        Code:
        . regress d1lifesat i.treat##i.female $xvarsls $exact [weight=w_treat_xvarsls], robust
        (analytic weights assumed)
        (sum of wgt is 1,706)
        note: welle_20 omitted because of collinearity
        note: welle_21 omitted because of collinearity
        note: welle_22 omitted because of collinearity
        note: welle_23 omitted because of collinearity
        
        Linear regression                               Number of obs     =     76,488
                                                        F(50, 76437)      =      21.69
                                                        Prob > F          =     0.0000
                                                        R-squared         =     0.3026
                                                        Root MSE          =     1.6336
        
        --------------------------------------------------------------------------------
                       |               Robust
             d1lifesat |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
        ---------------+----------------------------------------------------------------
               1.treat |  -.6967529   .0905155    -7.70   0.000    -.8741628   -.5193429
              1.female |   .0765075   .0581221     1.32   0.188    -.0374114    .1904264
                       |
          treat#female |
                  1 1  |   .3053028   .1285729     2.37   0.018     .0533006     .557305
                       |
                   age |   .0207818   .0518195     0.40   0.688    -.0807841    .1223478
                  age2 |  -.0004115   .0006461    -0.64   0.524    -.0016779    .0008549
                   mig |   .1331543   .1297604     1.03   0.305    -.1211754    .3874841
             foreigner |   .0157138   .1585704     0.10   0.921    -.2950833    .3265109
               lifesat |  -.7424799   .0997517    -7.44   0.000    -.9379927   -.5469672
              lifesat2 |      .0142   .0081556     1.74   0.082    -.0017848    .0301849
                   uni |   .2703843   .1009595     2.68   0.007     .0725041    .4682645
              voctrain |  -.0573165   .0901034    -0.64   0.525    -.2339187    .1192858
             pgerwzeit |   .0107299   .0133742     0.80   0.422    -.0154836    .0369433
            pgerwzeit2 |   6.72e-06   .0004642     0.01   0.988    -.0009032    .0009166
               nounemp |  -.0223735    .071981    -0.31   0.756    -.1634559    .1187089
               pgexpft |  -.0106711   .0164342    -0.65   0.516    -.0428822    .0215399
              pgexpft2 |    .000426   .0005004     0.85   0.395    -.0005549    .0014068
                kids_1 |  -.1842164   .0945187    -1.95   0.051    -.3694725    .0010398
                kids_2 |  -.2643236   .1338055    -1.98   0.048    -.5265816   -.0020655
                kids_3 |  -.3453706   .2135555    -1.62   0.106    -.7639383    .0731971
               badhlth |  -.0628414   .1312146    -0.48   0.632    -.3200214    .1943386
              goodhlth |   .3649959   .0769654     4.74   0.000     .2141442    .5158477
            pgpsbil2_1 |   .3348192   .4298822     0.78   0.436    -.5077478    1.177386
            pgpsbil2_2 |   .3058522      .4273     0.72   0.474    -.5316537    1.143358
            pgpsbil2_3 |   .5166362   .4401326     1.17   0.240    -.3460215    1.379294
            pgpsbil2_4 |   .3486262    .429193     0.81   0.417      -.49259    1.189842
        household_size |   .0685323   .0551987     1.24   0.214    -.0396569    .1767214
                   own |   .0974347   .0703691     1.38   0.166    -.0404884    .2353578
             religious |   -.002747   .0694901    -0.04   0.968    -.1389472    .1334532
                mardur |  -.0049592   .0066328    -0.75   0.455    -.0179595    .0080411
           marriages_1 |  -.0180215   .1170595    -0.15   0.878    -.2474576    .2114146
                  hhw4 |  -.0080747   .0105341    -0.77   0.443    -.0287214    .0125721
               welle_1 |   .3056924   .2717534     1.12   0.261    -.2269429    .8383277
               welle_2 |  -.1443657   .2383538    -0.61   0.545     -.611538    .3228066
               welle_3 |  -.1749228   .2392728    -0.73   0.465    -.6438962    .2940507
               welle_4 |   .1753217   .2520943     0.70   0.487    -.3187818    .6694252
               welle_5 |  -.0950629   .2535304    -0.37   0.708    -.5919811    .4018554
               welle_6 |  -.4348744   .2836759    -1.53   0.125    -.9908778     .121129
               welle_7 |  -.4871546   .2421371    -2.01   0.044    -.9617421   -.0125672
               welle_8 |  -.3247796   .2193489    -1.48   0.139    -.7547023    .1051431
               welle_9 |  -.2417041   .2202981    -1.10   0.273    -.6734872     .190079
              welle_10 |   .0033921   .2246698     0.02   0.988    -.4369597    .4437438
              welle_11 |  -.1439369   .2254932    -0.64   0.523    -.5859024    .2980286
              welle_12 |  -.2399553   .2373318    -1.01   0.312    -.7051245    .2252139
              welle_13 |   .2220288   .2266485     0.98   0.327    -.2222011    .6662587
              welle_14 |  -.0626054   .2272806    -0.28   0.783    -.5080743    .3828635
              welle_15 |  -.2970713   .2383165    -1.25   0.213    -.7641705    .1700279
              welle_16 |   .1871886   .2519749     0.74   0.458    -.3066809     .681058
              welle_17 |   .2080998   .2343989     0.89   0.375    -.2513209    .6675205
              welle_18 |   .0124528    .216621     0.06   0.954    -.4121234    .4370289
              welle_19 |   .1036107   .2143855     0.48   0.629    -.3165839    .5238053
              welle_20 |          0  (omitted)
              welle_21 |          0  (omitted)
              welle_22 |          0  (omitted)
              welle_23 |          0  (omitted)
                 _cons |   3.768597   1.104818     3.41   0.001      1.60316    5.934034
        --------------------------------------------------------------------------------
        so that would mean that the difference between men and women is about 0.3053 and its signifcant? Am I interpreting this correctly?

        (The estimates in my analysis for d1lifesat from the code above are - 0.6967 for men and -0.3915 for women which matches the estimates from the code you wrote
        --> -0.6967 + 0.3053 = -0.3914)

        Thank you very much

        Comment


        • #5
          Konstantin:
          the -1.treat- is the so called main conditional (on interaction) effect on the dependent variable of treat_1 for a male patient;
          the -1.female- is the so called main conditional (on interaction) effect on the dependent variable of treat_0 for a female patient;
          the -treat#female- tells you that the interaction between treat_1 and female patients actually reaches statistical significance.
          -squared age can be removed from predictors as there's no evidence of turning point.
          Kind regards,
          Carlo
          (Stata 19.0)

          Comment

          Working...
          X