Announcement

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

  • Confusion about the command "suest"

    Hi Statalist,

    I think I want to use the command "suest" to test if two coefficient estimates are the same from two different regression models. However, I think I am experiencing problems as I use first differenced models, which I have read on the statalist does not function well with the "suest" command. A further problem is that one of the regression models is weighted by the the weight of the municipality as a share of the total population. This produce the error "inconsistent weighting types" when using "suest"

    The data that I use is paneldata following the same municipalitites over 20 years. I run a simple first difference model where the output is one year change in local unemployment rate (LUR) and the explanatory variable is a one year change in the a share of refugees (RS) in the municipality relative to the municipality population. The erors are clustered at municipality level to take into account correlation within municipalities and I further control for time fixed effects by including a year dummy.
    I want to make a robustness test to check if the coefficient estimate changes significantly when weighting the effects by the size of the municipality relative to the total population in the country. Thus I write:

    * Weighted regression
    reg LUR RS i.year [weight=pop_share], nocons cluster(idnewM)
    estimates store weight

    * Unweighted regression
    reg LUR RS i.year, nocons cluster(idnewM)
    estimates store noweight

    suest weight noweight
    test [weight_mean]RS =[noweight_mean]RS

    However, the error message replies "inconsistent weighting types"


    I think I found out that I should not cluster in the regression but instead specify it in the suest command, but the error still says "inconsistent weighting types". I have tried othe weighting types as pweight and aweight. But I stille cannot get it to work. The stata I use is 13.0

    I hope someone is able to help me

    Kind regars Cecilie



  • #2
    I usually suggest that one runs a combined regression in cases where suest presents difficulties, but there are a few complications with what you want to do if you were to follow my advice. These largely relate to the the presence of the time dummies in the regressions combined with the no constant conditions. In the joint regression, Stata will omit only one set of dummies, whereas you need these to be two. Trying to do this manually in regress is difficult, if not impossible, when using factor variables. This is the main complicating factor... otherwise, implementing different weights is not an issue as you can think of the "unweighted regression" as one which uses constant weights.The good news is that Stata has cnsreg (constrained linear regression), and you can specify what dummies to omit using constraints. You can follow the procedure from the example below.

    Code:
    webuse grunfeld, clear
    set seed 2019
    gen weight= runiformint(1, 10)
    *REGRESSION WITH NO WEIGHTS
    regress invest mvalue kstock i.year,  nocons cluster(company)
    *REGRESSION WITH WEIGHTS
    regress invest mvalue kstock i.year [weight=weight], nocons cluster(company)
    *DUPLICATE OBSERVATIONS
    expand 2, gen(set)
    *GET MEAN OF ORIGINAL OBSERVATIONS TO USE AS WEIGHT FOR DUPLICATED GROUP
    qui sum weight if set==0
    local mean= r(mean)
    replace weight= `mean' if set==1
    *SPECIFY DIFFERENT PANEL IDs FOR DUPLICATES
    replace company= company*100  if set==1
    *SPECIFY WHAT DUMMIES TO OMIT AS CONSTRAINTS
    constraint 1 1.set#1935.year==0
    constraint 2 0.set#1935.year==0
    *RUN THE JOINT CONSTRAINED REGRESSION
    cnsreg invest i.set#(c.mvalue c.kstock i.year) [pw=weight], nocons cluster(company) constraint(1/2)


    Results:

    Code:
    . *REGRESSION WITH NO WEIGHTS
    
    .
    . regress invest mvalue kstock i.year,  nocons cluster(company)
    
    Linear regression                               Number of obs     =        200
                                                    F(9, 9)           =          .
                                                    Prob > F          =          .
                                                    R-squared         =     0.8738
                                                    Root MSE          =     97.981
    
                                   (Std. Err. adjusted for 10 clusters in company)
    ------------------------------------------------------------------------------
                 |               Robust
          invest |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
    -------------+----------------------------------------------------------------
          mvalue |   .1162778   .0180255     6.45   0.000     .0755012    .1570543
          kstock |   .2200048   .1046285     2.10   0.065    -.0166812    .4566908
                 |
            year |
           1936  |  -40.24804    18.8184    -2.14   0.061    -82.81822    2.322151
           1937  |   -57.3937   27.15989    -2.11   0.064    -118.8336    4.046235
           1938  |  -51.61877   20.26597    -2.55   0.031    -97.46357   -5.773965
           1939  |  -79.30263   28.20118    -2.81   0.020    -143.0981   -15.50714
           1940  |  -53.53734   18.40301    -2.91   0.017    -95.16784   -11.90684
           1941  |  -25.68905   18.75568    -1.37   0.204    -68.11735    16.73924
           1942  |  -24.59984   18.32887    -1.34   0.212    -66.06262    16.86293
           1943  |  -44.92243    17.0865    -2.63   0.027    -83.57477   -6.270082
           1944  |  -45.22106    13.8562    -3.26   0.010    -76.56598   -13.87615
           1945  |  -56.64393   17.55436    -3.23   0.010    -96.35465   -16.93321
           1946  |  -30.04663   17.80135    -1.69   0.126    -70.31608    10.22283
           1947  |  -28.43069    28.9358    -0.98   0.352    -93.88803    37.02664
           1948  |  -27.13206   43.28527    -0.63   0.546    -125.0501    70.78601
           1949  |  -52.00575   43.09285    -1.21   0.258    -149.4886    45.47706
           1950  |  -51.54159   39.85798    -1.29   0.228    -141.7066    38.62343
           1951  |  -34.74589   48.80717    -0.71   0.495    -145.1554     75.6636
           1952  |  -28.68071   51.62101    -0.56   0.592    -145.4556    88.09412
           1953  |  -20.52594   42.81266    -0.48   0.643    -117.3749    76.32302
           1954  |  -35.33443   30.16599    -1.17   0.272    -103.5746    32.90578
    ------------------------------------------------------------------------------
    Code:
     *REGRESSION WITH WEIGHTS
    
    .
    . regress invest mvalue kstock i.year [weight=weight], nocons cluster(company)
    (analytic weights assumed)
    (sum of wgt is 1,144)
    
    Linear regression                               Number of obs     =        200
                                                    F(9, 9)           =          .
                                                    Prob > F          =          .
                                                    R-squared         =     0.8696
                                                    Root MSE          =      100.2
    
                                   (Std. Err. adjusted for 10 clusters in company)
    ------------------------------------------------------------------------------
                 |               Robust
          invest |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
    -------------+----------------------------------------------------------------
          mvalue |   .1210293    .024505     4.94   0.001     .0655951    .1764635
          kstock |    .234466   .1034759     2.27   0.050     .0003873    .4685447
                 |
            year |
           1936  |   -59.3161   22.44189    -2.64   0.027    -110.0832   -8.549024
           1937  |  -68.50351   26.88641    -2.55   0.031    -129.3248   -7.682222
           1938  |  -48.73969   24.58883    -1.98   0.079    -104.3635    6.884105
           1939  |  -64.54266    23.0787    -2.80   0.021    -116.7503   -12.33502
           1940  |   -39.9201   18.45078    -2.16   0.059    -81.65867    1.818469
           1941  |  -46.75725   22.23575    -2.10   0.065    -97.05801    3.543515
           1942  |  -23.26965    15.5821    -1.49   0.170    -58.51882    11.97952
           1943  |  -56.03014   30.68836    -1.83   0.101     -125.452    13.39175
           1944  |  -61.95243   21.30913    -2.91   0.017     -110.157   -13.74782
           1945  |  -72.67158   20.11169    -3.61   0.006    -118.1674   -27.17578
           1946  |   -52.6564   16.44474    -3.20   0.011    -89.85698   -15.45581
           1947  |  -23.67241   33.24003    -0.71   0.494    -98.86658    51.52175
           1948  |   7.057178   54.41995     0.13   0.900    -116.0493    130.1637
           1949  |  -54.34019   50.33556    -1.08   0.308    -168.2071    59.52675
           1950  |  -54.78148   34.45079    -1.59   0.146    -132.7146    23.15162
           1951  |  -50.99214   40.90794    -1.25   0.244    -143.5323    41.54806
           1952  |  -12.84685   64.75755    -0.20   0.847    -159.3386    133.6449
           1953  |  -13.43877   53.68401    -0.25   0.808    -134.8804    108.0029
           1954  |  -63.43624   38.77314    -1.64   0.136    -151.1472     24.2747
    ------------------------------------------------------------------------------
    Code:
     
    . *RUN THE JOINT CONSTRAINED REGRESSION
    
    .
    . cnsreg invest i.set#(c.mvalue c.kstock i.year) [pw=weight], nocons cluster(company) constraint(1/2)
    
    Constrained linear regression                   Number of obs     =        400
                                                    F(  18,    358)   =       3.89
                                                    Prob > F          =     0.0000
                                                    Root MSE          =   237.0083
    
     ( 1)  1.set#1935b.year = 0
                                   (Std. Err. adjusted for 20 clusters in company)
    ------------------------------------------------------------------------------
                 |               Robust
          invest |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
    -------------+----------------------------------------------------------------
    set#c.mvalue |
              0  |   .1210293   .0238814     5.07   0.000     .0740639    .1679947
              1  |   .1162778   .0175668     6.62   0.000     .0817307    .1508248
                 |
    set#c.kstock |
              0  |    .234466   .1008425     2.33   0.021     .0361479    .4327841
              1  |   .2200048   .1019657     2.16   0.032     .0194777    .4205318
                 |
        set#year |
         0 1936  |   -59.3161   21.87075    -2.71   0.007    -102.3274    -16.3048
         0 1937  |  -68.50351   26.20217    -2.61   0.009     -120.033     -16.974
         0 1938  |  -48.73969   23.96306    -2.03   0.043    -95.86574   -1.613644
         0 1939  |  -64.54266   22.49136    -2.87   0.004    -108.7744   -20.31087
         0 1940  |   -39.9201   17.98122    -2.22   0.027    -75.28219   -4.558009
         0 1941  |  -46.75725   21.66986    -2.16   0.032    -89.37347   -4.141024
         0 1942  |  -23.26965   15.18555    -1.53   0.126    -53.13374     6.59444
         0 1943  |  -56.03014   29.90736    -1.87   0.062    -114.8463    2.786038
         0 1944  |  -61.95243   20.76683    -2.98   0.003    -102.7927   -21.11213
         0 1945  |  -72.67158   19.59986    -3.71   0.000    -111.2169   -34.12626
         0 1946  |   -52.6564   16.02623    -3.29   0.001    -84.17378   -21.13902
         0 1947  |  -23.67241   32.39409    -0.73   0.465    -87.37903     40.0342
         0 1948  |   7.057178     53.035     0.13   0.894    -97.24211    111.3565
         0 1949  |  -54.34019   49.05455    -1.11   0.269    -150.8115    42.13109
         0 1950  |  -54.78148   33.57403    -1.63   0.104    -120.8086    11.24564
         0 1951  |  -50.99214   39.86686    -1.28   0.202    -129.3948    27.41052
         0 1952  |  -12.84685    63.1095    -0.20   0.839    -136.9588    111.2651
         0 1953  |  -13.43877   52.31778    -0.26   0.797    -116.3276    89.45003
         0 1954  |  -63.43624   37.78639    -1.68   0.094    -137.7474    10.87494
         1 1935  |          0  (omitted)
         1 1936  |  -40.24804   18.33949    -2.19   0.029     -76.3147   -4.181374
         1 1937  |   -57.3937   26.46868    -2.17   0.031    -109.4473   -5.340055
         1 1938  |  -51.61877   19.75021    -2.61   0.009    -90.45978   -12.77776
         1 1939  |  -79.30263   27.48347    -2.89   0.004     -133.352    -25.2533
         1 1940  |  -53.53734   17.93466    -2.99   0.003    -88.80787   -18.26681
         1 1941  |  -25.68905   18.27836    -1.41   0.161     -61.6355    10.25739
         1 1942  |  -24.59984   17.86241    -1.38   0.169    -59.72827    10.52859
         1 1943  |  -44.92243   16.65166    -2.70   0.007    -77.66978   -12.17507
         1 1944  |  -45.22106   13.50357    -3.35   0.001    -71.77736   -18.66477
         1 1945  |  -56.64393   17.10761    -3.31   0.001    -90.28797   -22.99989
         1 1946  |  -30.04663   17.34832    -1.73   0.084    -64.16404    4.070788
         1 1947  |  -28.43069    28.1994    -1.01   0.314    -83.88799     27.0266
         1 1948  |  -27.13206   42.18368    -0.64   0.521     -110.091    55.82689
         1 1949  |  -52.00575   41.99616    -1.24   0.216    -134.5959    30.58443
         1 1950  |  -51.54159   38.84362    -1.33   0.185    -127.9319    24.84875
         1 1951  |  -34.74589   47.56505    -0.73   0.466    -128.2879    58.79614
         1 1952  |  -28.68071   50.30728    -0.57   0.569    -127.6156    70.25422
         1 1953  |  -20.52594    41.7231    -0.49   0.623    -102.5791    61.52723
         1 1954  |  -35.33443   29.39828    -1.20   0.230    -93.14947     22.4806
    ------------------------------------------------------------------------------

    Comment

    Working...
    X