Announcement

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

  • Help with "test" command

    I’m using Stata 16.1 on iMac.

    I have run two probit models using the same variables but different data. I want to test the equality of the same coefficients in the two models.

    Here is the data used in the example below, taken from the Stata file "union".

    Code:
    * Example generated by -dataex-. For more info, type help dataex
    clear
    input int idcode byte(year age grade not_smsa south union black) float subset
     1 72 20 12 0 0 1 1 1
     2 71 19 12 0 0 0 1 1
     3 70 24 12 0 0 1 1 1
     4 70 24 17 0 0 1 0 1
     5 70 24 12 0 0 0 0 1
     6 71 24 12 0 0 0 0 1
     7 70 21 12 0 0 0 0 1
     9 70 18 12 0 0 1 0 1
    10 70 18 10 0 0 0 0 1
    12 77 29 17 0 0 0 0 1
    13 70 22 14 0 0 0 0 1
    14 78 30 14 0 0 0 0 1
    15 72 23 15 0 0 0 0 1
    16 70 21 15 0 0 0 0 1
    17 70 21 15 0 0 0 0 1
    18 77 28 15 0 0 0 0 1
    19 70 21 15 0 0 0 0 1
    20 70 21 15 0 0 0 0 1
    21 72 23 15 0 0 0 0 1
    22 70 22 15 0 0 0 0 1
    23 70 23 14 0 0 0 0 1
    24 70 23 14 0 0 0 0 1
    25 70 24 14 0 0 0 0 1
    26 70 25 14 0 0 0 0 1
    27 70 24 14 0 0 0 0 1
    28 77 28 13 0 0 0 0 2
    29 70 21 13 0 0 0 0 2
    30 72 21  8 0 0 1 0 2
    33 70 24 12 0 0 0 0 2
    35 82 29 11 0 0 0 0 2
    36 70 18 12 0 0 0 0 2
    38 70 25 12 0 0 0 0 2
    39 82 38 16 0 0 0 0 2
    40 71 20 14 0 0 0 0 2
    41 70 22 12 0 0 0 0 2
    42 72 19 12 0 0 0 0 2
    43 78 25 16 0 0 0 0 2
    44 70 23 16 0 0 0 0 2
    45 72 19 12 0 0 1 0 2
    46 77 33 17 0 0 0 0 2
    47 71 18  9 0 0 0 0 2
    48 87 34 15 0 0 0 0 2
    49 70 23 12 0 0 0 0 2
    50 72 20 12 0 0 0 0 2
    51 70 19 12 0 0 1 0 2
    53 72 18 12 0 0 0 0 2
    54 77 28 12 0 0 0 0 2
    55 70 26 12 0 0 0 0 2
    56 77 28 12 0 0 0 0 2
    57 71 25 12 0 0 0 0 2
    end
    Here is the code I ran:

    probit union year age grade not_smsa south if subset == 1
    estimates store m1
    probit union year age grade not_smsa south if subset == 2
    estimates store m2
    suest m1 m2
    test [m1_mean = m2_mean]:age
    test [m1 = m2]:age

    After the "test" commands I got this:

    . test [m1_mean = m2_mean]:age
    equation m1_mean not found
    r(303);

    . test [m1 = m2]:age
    equation m1 not found
    r(303);

    Why am I not getting the test results I want?

    Thanks for any help,

    Wayne Sandholtz

  • #2
    Look more closely at the -suest- output:
    Code:
    . suest m1 m2
    
    Simultaneous results for m1, m2                             Number of obs = 50
    
    ------------------------------------------------------------------------------
                 |               Robust
                 | Coefficient  std. err.      z    P>|z|     [95% conf. interval]
    -------------+----------------------------------------------------------------
    m1_union     |
            year |   -.057327   .2099981    -0.27   0.785    -.4689157    .3542618
             age |  -.0914122   .1761171    -0.52   0.604    -.4365954    .2537711
           grade |  -.0478224   .2511217    -0.19   0.849    -.5400119     .444367
        not_smsa |          0  (omitted)
           south |          0  (omitted)
           _cons |   5.759789   12.24642     0.47   0.638    -18.24275    29.76233
    -------------+----------------------------------------------------------------
    m2_union     |
            year |   .0185441   .1619318     0.11   0.909    -.2988364    .3359247
             age |  -.2054886   .1122207    -1.83   0.067    -.4254371    .0144598
           grade |  -.3304624   .2586328    -1.28   0.201    -.8373734    .1764486
        not_smsa |          0  (omitted)
           south |          0  (omitted)
           _cons |   5.756358   11.64032     0.49   0.621    -17.05825    28.57096
    ------------------------------------------------------------------------------
    [Emphasis added]
    The names that -suest- gives to these estimates are not m1_mean and m2_mean. They are m1_union and m2_union. In your -test- command you have to use the same names that -suest- gave them. You are probably confused by having seen examples following linear regressions, where -suest- does call them m1_mean and m2_mean. But -suest- chooses different names for different estimation commands.

    If you do that, you get your results:
    Code:
    . test [m1_union = m2_union]: age
    
     ( 1)  [m1_union]age - [m2_union]age = 0
    
               chi2(  1) =    0.30
             Prob > chi2 =    0.5849

    Comment


    • #3
      I addition to Clyde's answer: If you are unsure what coefficients are called internally by Stata, you can add the coeflegend option to many estimation commands:

      Code:
      . suest m1 m2, coeflegend
      
      Simultaneous results for m1, m2                             Number of obs = 50
      
      ------------------------------------------------------------------------------
                   | Coefficient  Legend
      -------------+----------------------------------------------------------------
      m1_union     |
              year |   -.057327  _b[m1_union:year]
               age |  -.0914122  _b[m1_union:age]
             grade |  -.0478224  _b[m1_union:grade]
          not_smsa |          0  _b[m1_union:o.not_smsa]
             south |          0  _b[m1_union:o.south]
             _cons |   5.759789  _b[m1_union:_cons]
      -------------+----------------------------------------------------------------
      m2_union     |
              year |   .0185441  _b[m2_union:year]
               age |  -.2054886  _b[m2_union:age]
             grade |  -.3304624  _b[m2_union:grade]
          not_smsa |          0  _b[m2_union:o.not_smsa]
             south |          0  _b[m2_union:o.south]
             _cons |   5.756358  _b[m2_union:_cons]
      ------------------------------------------------------------------------------
      ---------------------------------
      Maarten L. Buis
      University of Konstanz
      Department of history and sociology
      box 40
      78457 Konstanz
      Germany
      http://www.maartenbuis.nl
      ---------------------------------

      Comment


      • #4
        Clyde, thanks very much for your help.

        Comment


        • #5
          And thank you Maarten; good suggestion.

          Comment


          • #6
            Dear Maarten Buis,
            Can the command suest be applied for 2 regressions with 2 different subsamples and cluster() option? For example: regress y1 x1 x2 if (prov_99 >= 1 & prov_99 < 11), cluster(prov_99) est store reg1 regress y1 x1 x2 if (prov_99 > 10 & prov_99 < 100), cluster(prov_99) est store reg2 Then, I want to test the coefficient of x2 in reg1 different from the coefficient of x2 in reg2 or not.

            Please, show me the detailed command if suest is till applied in my example because I have just learnt about suest command.

            Thank you in advance!

            Best Regards,
            Thon Hoang

            Comment


            • #7
              Yes and no. You can definitely apply -suest- to regressions estimated on different samples. In fact, that it one of its most common uses. But if you want clustered standard errors, you have to first run the regressions with ordinary standard errors, and then specify clustered standard errors on the -suest- command. -suest- will not accept estimates from regressions with clustered or robust errors, but it will cluster or robustify them for the combined result if you ask it to.

              Comment


              • #8
                Dear Clyde Schechter,

                Thank you for your immediate response.
                After running the regressions without cluster() option, I do still fail with -suest-. Then I found that in my regressions have province fixed effects. And the fixed effects could be the main reason for the failure. The error below appears. That means -suest- cannot be applied for the regression with fixed effect, right?
                regress y1 x1 x2 i.prov_99 if (prov_99 >= 1 & prov_99 < 11)
                est store reg1
                regress y1 x1 x2 i.prov_99 if (prov_99 > 10 & prov_99 < 100)
                est store reg2
                suest reg1 reg2
                Then the error is:
                prov_99: factor variable base category conflict

                Thank you in advance!

                Best Regards,
                Thon Hoang

                Comment


                • #9
                  The problem is that you have those i.prov_99 factor variables, and because they are non-overlapping between the two regressions, they necessarily have different base categories. So -suest- can't handle that.

                  You could get around that by creating homebrew indicator ("dummy") variables for the prov_99 levels instead of using factor variable notation; -suest- would be OK with that. But that's a bit on the messy side. I think that for your overall purpose, you are better off doing this by using interactions.
                  Code:
                  gen group = 1 if inrange(prov_99, 1, 10)
                  replace group = 2 if inrange(prov_99, 11, 99)
                  xtset prov_99
                  xtreg y1 i.group##(c.x1 c.x2), fe vce(cluster prov_99)
                  N.B. I'm assuming x1 and x2 are continuous. If they are discrete, replace c.x* by i.x*.

                  When you run this, you will find that the group variable itself (but not its interactions with x1 and x2) is omitted. This is because group is colinear with the prov_99 fixed effects. This is not a problem. It does mean that the group effect itself is not estimable in this model--but you don't need that to see if the coefficients of the x* variables differ across the two subpopulations. Your focus is in the coefficients of 2.group#c.x1 and 2.group#c.x2. These coefficients represent, respectively, the subpopulation differences in the coefficients of x1 and x2.

                  Comment


                  • #10
                    Thank you a lot for your help, Mr. Schechter!

                    Comment

                    Working...
                    X