Announcement

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

  • Regress at the mean of age

    Hello,

    I am struggling a bit with my regression. My basic regression looks like this:
    Code:
     svy: regress lnhourlyw_w i.ib9999.arrival if year==2004
    So, I am regressing log wages on immigrants arrival where arrival=9999 is coded as being native. I am looking for cohorts effects here, how is the immigrant log wage of these immigrant arrivals relative to native in the year 2004.

    However, in a second step, I would like to have the age-adjusted wage differential of immigrant to native. So, I am using a third-order polynomial in workers age (bb03a, bb03a2=bb03a^2 and bb03a3=bb03a^3) additionally. Regression looks like:

    Code:
    svy: regress lnhourlyw_w bb03a bb03a2 bb03a3 c.bb03a##i.ib9999.arrival c.bb03a2##i.ib9999.arrival c.bb03a3##i.ib9999.arrival  i.ib9999.arrival if year==2004
    However, I would like to have estimates on the cohorts predicted at the mean of age of the population. So, the above regression at mean of bb03a. I was thinking on using the code:

    Code:
    svy: margins, at(bb03a=41 arrival)
    But the output says, last estimates not found...

    Output on the first regression is:

    Code:
    svy: regress lnhourlyw_w i.ib9999.arrival if year==2004
    (running regress on estimation sample)
    
    Survey: Linear regression
    
    Number of strata   =         1                  Number of obs     =    10,726
    Number of PSUs     =    10,726                  Population size   =    1,317,293
    Design df         =    10,725
    F(   6,  10720)   =    99.52
    Prob > F          =    0.0000
    R-squared         =    0.0279
    
        
    Linearized
    lnhourlyw_w       Coef.   Std. Err.      t    P>t     [95% Conf.    Interval]
        
    arrival
    0    -.1686351   .0151419   -11.14   0.000     -.198316    -.1389543
    1980    -.1678049   .0202635    -8.28   0.000     -.207525    -.1280847
    1985    -.2158353   .0165672   -13.03   0.000    -.2483101    -.1833604
    1990    -.2542113   .0122076   -20.82   0.000    -.2781405    -.2302822
    1995    -.1508089   .0222109    -6.79   0.000    -.1943463    -.1072715
    2000    -.0889885   .0228124    -3.90   0.000     -.133705    -.044272
    
    _cons    3.689774   .0057737   639.07   0.000     3.678457    3.701092
    Output on second regression:

    Code:
    . svy: regress lnhourlyw_w bb03a bb03a2 bb03a3 c.bb03a##i.ib9999.arrival c.bb03a2##i.ib9999.ar
    > rival c.bb03a3##i.ib9999.arrival  i.ib9999.arrival if year==2004
    (running regress on estimation sample)
    
    Survey: Linear regression
    
    Number of strata   =         1                  Number of obs     =     10,726
    Number of PSUs     =    10,726                  Population size   =  1,317,293
    Design df         =     10,725
    F(  27,  10699)   =     114.85
    Prob > F          =     0.0000
    R-squared         =     0.2216
    
    
    Linearized
    lnhourlyw_w       Coef.   Std. Err.      t    P>t     [95% Conf. Interval]
    
    bb03a    .1339664   .0152074     8.81   0.000     .1041572    .1637757
    bb03a2   -.0022769      .0004    -5.69   0.000    -.0030609    -.001493
    bb03a3    .0000126   3.33e-06     3.79   0.000     6.09e-06    .0000191
    bb03a           0  (omitted)
    
    arrival
    0     26.78865   12.59468     2.13   0.033     2.100745    51.47656
    1980     14.41574   8.178109     1.76   0.078    -1.614872    30.44634
    1985     6.221622   4.590746     1.36   0.175    -2.777089    15.22033
    1990     .4615053   1.790314     0.26   0.797    -3.047841    3.970851
    1995     4.245991   1.883982     2.25   0.024     .5530385    7.938944
    2000    -1.446823   .9976211    -1.45   0.147    -3.402345    .5086989
    
    arrival#c.bb03a
    0    -1.455179   .6982813    -2.08   0.037    -2.823939   -.0864182
    1980    -.8610379   .4995845    -1.72   0.085    -1.840316    .1182402
    1985    -.3955509   .3064418    -1.29   0.197    -.9962336    .2051318
    1990    -.0196936    .126786    -0.16   0.877    -.2682177    .2288306
    1995    -.3470192   .1477938    -2.35   0.019    -.6367225    -.057316
    2000      .085056   .0853952     1.00   0.319    -.0823344    .2524463
    
    bb03a2           0  (omitted)
    
    arrival#c.bb03a2
    0     .0258944   .0128356     2.02   0.044     .0007342    .0510546
    1980     .0163834   .0100669     1.63   0.104    -.0033496    .0361163
    1985      .007667   .0067382     1.14   0.255    -.0055412    .0208751
    1990    -.0002907   .0029442    -0.10   0.921    -.0060619    .0054805
    1995     .0087511   .0037584     2.33   0.020      .001384    .0161182
    2000    -.0015658   .0023226    -0.67   0.500    -.0061184    .0029869
    
    bb03a3           0  (omitted)
    
    arrival#c.bb03a3
    0    -.0001527   .0000782    -1.95   0.051    -.0003061    6.05e-07
    1980    -.0001011   .0000669    -1.51   0.130    -.0002322    .0000299
    1985    -.0000473   .0000488    -0.97   0.332    -.0001429    .0000483
    1990     6.95e-06   .0000224     0.31   0.756     -.000037    .0000509
    1995    -.0000703   .0000309    -2.28   0.023    -.0001308   -9.75e-06
    2000     9.36e-06     .00002     0.47   0.640    -.0000299    .0000486
    
    _cons    1.260013   .1825066     6.90   0.000     .9022663     1.61776
    Code:
    * Example generated by -dataex-. To    install:    ssc    install    dataex
    clear
    input int bb03a float(bb03a2 bb03a3    arrival)
    18 324 5832 9999
    18 324 5832 9999
    18 324 5832 9999
    18 324 5832 9999
    18 324 5832 9999
    18 324 5832 9999
    18 324 5832 9999
    18 324 5832 9999
    18 324 5832 9999
    18 324 5832 9999
    18 324 5832 9999
    18 324 5832 9999
    18 324 5832 9999
    18 324 5832 9999
    18 324 5832 9999
    18 324 5832 9999
    18 324 5832 9999
    18 324 5832 9999
    18 324 5832 9999
    18 324 5832 9999
    18 324 5832 9999
    18 324 5832 9999
    18 324 5832 9999
    18 324 5832 9999
    18 324 5832 9999
    18 324 5832 9999
    18 324 5832 9999
    18 324 5832 9999
    18 324 5832 9999
    18 324 5832 9999
    18 324 5832 9999
    18 324 5832 9999
    18 324 5832 9999
    18 324 5832 9999
    18 324 5832 9999
    18 324 5832 9999
    18 324 5832 9999
    18 324 5832 9999
    18 324 5832 9999
    18 324 5832 9999
    18 324 5832 9999
    18 324 5832 9999
    18 324 5832 9999
    18 324 5832 9999
    18 324 5832 9999
    18 324 5832 9999
    18 324 5832 9999
    18 324 5832 9999
    18 324 5832 9999
    18 324 5832 9999
    18 324 5832 9999
    18 324 5832 9999
    18 324 5832 9999
    18 324 5832 9999
    19 361 6859 9999
    19 361 6859 9999
    19 361 6859 9999
    19 361 6859 9999
    19 361 6859 9999
    19 361 6859 9999
    19 361 6859 9999
    19 361 6859 9999
    19 361 6859 9999
    19 361 6859 9999
    19 361 6859 9999
    19 361 6859 9999
    19 361 6859 9999
    19 361 6859 9999
    19 361 6859 9999
    19 361 6859 9999
    19 361 6859 9999
    19 361 6859 9999
    19 361 6859 9999
    19 361 6859 9999
    19 361 6859 9999
    19 361 6859 9999
    19 361 6859 9999
    19 361 6859 9999
    19 361 6859 9999
    19 361 6859 9999
    19 361 6859 9999
    19 361 6859 9999
    19 361 6859 9999
    19 361 6859 9999
    19 361 6859 9999
    19 361 6859 9999
    19 361 6859 9999
    19 361 6859 9999
    19 361 6859 9999
    19 361 6859 9999
    19 361 6859 9999
    19 361 6859 9999
    19 361 6859 9999
    19 361 6859 9999
    19 361 6859 9999
    19 361 6859 9999
    19 361 6859 9999
    19 361 6859 9999
    19 361 6859 9999
    19 361 6859 9999
    19 361 6859 9999
    19 361 6859 9999
    19 361 6859 9999
    19 361 6859 9999
    19 361 6859 9999
    19 361 6859 9999
    19 361 6859 9999
    19 361 6859 9999
    19 361 6859 9999
    19 361 6859 9999
    19 361 6859 9999
    19 361 6859 9999
    19 361 6859 9999
    19 361 6859 9999
    19 361 6859 9999
    19 361 6859 9999
    19 361 6859 9999
    19 361 6859 9999
    19 361 6859 9999
    19 361 6859 9999
    19 361 6859 9999
    19 361 6859 9999
    19 361 6859 9999
    19 361 6859 9999
    19 361 6859 9999
    19 361 6859 9999
    19 361 6859 9999
    19 361 6859 9999
    19 361 6859 9999
    19 361 6859 9999
    19 361 6859 9999
    19 361 6859 9999
    19 361 6859 9999
    19 361 6859 9999
    19 361 6859 9999
    19 361 6859 9999
    19 361 6859 9999
    19 361 6859 9999
    19 361 6859 9999
    19 361 6859 9999
    19 361 6859 9999
    19 361 6859 9999
    19 361 6859 9999
    19 361 6859 9999
    19 361 6859 9999
    19 361 6859 9999
    19 361 6859 9999
    19 361 6859 9999
    19 361 6859 9999
    19 361 6859 9999
    19 361 6859 9999
    19 361 6859 9999
    19 361 6859 9999
    19 361 6859 9999
    19 361 6859 9999
    19 361 6859 9999
    19 361 6859 9999
    19 361 6859 9999
    19 361 6859 9999
    19 361 6859 9999
    19 361 6859 9999
    19 361 6859 9999
    19 361 6859 9999
    19 361 6859 9999
    19 361 6859 9999
    19 361 6859 9999
    19 361 6859 9999
    19 361 6859 9999
    19 361 6859 2010
    19 361 6859 9999
    19 361 6859 9999
    19 361 6859 9999
    19 361 6859 9999
    19 361 6859 9999
    19 361 6859 9999
    19 361 6859 9999
    19 361 6859 9999
    19 361 6859 9999
    19 361 6859 9999
    19 361 6859 9999
    19 361 6859 9999
    19 361 6859 9999
    19 361 6859 9999
    19 361 6859 9999
    19 361 6859 9999
    19 361 6859 9999
    19 361 6859 9999
    19 361 6859 9999
    19 361 6859 9999
    19 361 6859 9999
    19 361 6859 9999
    19 361 6859 9999
    19 361 6859 9999
    19 361 6859 9999
    19 361 6859 9999
    19 361 6859 9999
    19 361 6859 9999
    19 361 6859 9999
    19 361 6859 9999
    20 400 8000 2005
    20 400 8000 9999
    20 400 8000 9999
    20 400 8000 9999
    20 400 8000 9999
    20 400 8000 9999
    20 400 8000 9999
    20 400 8000 9999
    20 400 8000 9999
    20 400 8000 9999
    20 400 8000 9999
    20 400 8000 2000
    20 400 8000 9999
    20 400 8000 9999
    20 400 8000 9999
    20 400 8000 9999
    20 400 8000 9999
    20 400 8000 9999
    20 400 8000 9999
    20 400 8000 9999
    20 400 8000 9999
    20 400 8000 9999
    20 400 8000 9999
    20 400 8000 9999
    20 400 8000 9999
    20 400 8000 9999
    20 400 8000 9999
    20 400 8000 9999
    20 400 8000 9999
    20 400 8000 9999
    20 400 8000 9999
    20 400 8000 9999
    20 400 8000 2000
    20 400 8000 9999
    20 400 8000 9999
    20 400 8000 9999
    20 400 8000 9999
    20 400 8000 9999
    20 400 8000 9999
    20 400 8000 9999
    20 400 8000 9999
    20 400 8000 9999
    20 400 8000 9999
    20 400 8000 9999
    20 400 8000 9999
    20 400 8000 9999
    20 400 8000 9999
    20 400 8000 9999
    20 400 8000 9999
    20 400 8000 9999
    20 400 8000 9999
    20 400 8000 2000
    20 400 8000 9999
    20 400 8000 9999
    20 400 8000 9999
    20 400 8000 9999
    20 400 8000 9999
    20 400 8000 9999
    20 400 8000 9999
    20 400 8000 9999
    20 400 8000 9999
    20 400 8000 9999
    20 400 8000 9999
    20 400 8000 9999
    20 400 8000 2005
    20 400 8000 9999
    20 400 8000 9999
    20 400 8000 9999
    20 400 8000 9999
    20 400 8000 9999
    20 400 8000 9999
    20 400 8000 9999
    20 400 8000 9999
    20 400 8000 9999
    20 400 8000 9999
    20 400 8000 9999
    20 400 8000 2000
    20 400 8000 9999
    20 400 8000 9999
    20 400 8000 9999
    20 400 8000 9999
    20 400 8000 9999
    20 400 8000 9999
    20 400 8000 9999
    20 400 8000 9999
    20 400 8000 9999
    20 400 8000 2000
    20 400 8000 9999
    20 400 8000 9999
    20 400 8000 9999
    20 400 8000 9999
    20 400 8000 9999
    20 400 8000 9999
    20 400 8000 9999
    20 400 8000 9999
    20 400 8000 9999
    20 400 8000 9999
    20 400 8000 9999
    20 400 8000 9999
    20 400 8000 9999
    20 400 8000 9999
    20 400 8000 9999
    20 400 8000 9999
    20 400 8000 9999
    20 400 8000 9999
    20 400 8000 9999
    20 400 8000 9999
    20 400 8000 9999
    20 400 8000 9999
    20 400 8000 9999
    20 400 8000 2000
    20 400 8000 9999
    20 400 8000 9999
    20 400 8000 9999
    20 400 8000 2000
    20 400 8000 9999
    20 400 8000 9999
    20 400 8000 9999
    20 400 8000 9999
    20 400 8000 9999
    20 400 8000 9999
    20 400 8000 9999
    20 400 8000 9999
    20 400 8000 9999
    20 400 8000 9999
    20 400 8000 9999
    20 400 8000 9999
    20 400 8000 9999
    20 400 8000 9999
    20 400 8000 9999
    20 400 8000 9999
    20 400 8000 9999
    20 400 8000 9999
    20 400 8000 9999
    20 400 8000 2000
    20 400 8000 9999
    20 400 8000 9999
    20 400 8000 9999
    20 400 8000 9999
    20 400 8000 9999
    20 400 8000 9999
    20 400 8000 9999
    20 400 8000 9999
    20 400 8000 9999
    20 400 8000 9999
    20 400 8000 9999
    20 400 8000 9999
    20 400 8000 9999
    20 400 8000 9999
    20 400 8000 9999
    20 400 8000 2000
    20 400 8000 9999
    20 400 8000 9999
    20 400 8000 9999
    20 400 8000 9999
    20 400 8000 9999
    20 400 8000 9999
    20 400 8000 9999
    20 400 8000 9999
    20 400 8000 9999
    20 400 8000 9999
    20 400 8000 9999
    20 400 8000 9999
    20 400 8000 9999
    20 400 8000 9999
    20 400 8000 9999
    20 400 8000 9999
    20 400 8000 9999
    20 400 8000 9999
    20 400 8000 9999
    20 400 8000 9999
    20 400 8000 9999
    20 400 8000 9999
    20 400 8000 9999
    20 400 8000 2010
    20 400 8000 9999
    20 400 8000 9999
    20 400 8000 2010
    20 400 8000 9999
    20 400 8000 9999
    20 400 8000 9999
    20 400 8000 9999
    20 400 8000 9999
    20 400 8000 9999
    20 400 8000 9999
    20 400 8000 9999
    20 400 8000 9999
    20 400 8000 9999
    20 400 8000 9999
    20 400 8000 9999
    20 400 8000 9999
    20 400 8000 9999
    20 400 8000 9999
    20 400 8000 9999
    20 400 8000 9999
    20 400 8000 9999
    20 400 8000 9999
    20 400 8000 2005
    20 400 8000 9999
    20 400 8000 9999
    20 400 8000 9999
    20 400 8000 9999
    20 400 8000 9999
    20 400 8000 9999
    20 400 8000 9999
    20 400 8000 9999
    20 400 8000 9999
    20 400 8000 9999
    21 441 9261 9999
    21 441 9261 9999
    21 441 9261 2005
    21 441 9261 9999
    21 441 9261 9999
    21 441 9261 9999
    21 441 9261 9999
    21 441 9261 9999
    21 441 9261 9999
    21 441 9261 9999
    21 441 9261 9999
    21 441 9261 9999
    21 441 9261 9999
    21 441 9261 2000
    21 441 9261 9999
    21 441 9261 9999
    21 441 9261 9999
    21 441 9261 9999
    21 441 9261 2000
    21 441 9261 9999
    21 441 9261 9999
    21 441 9261 9999
    21 441 9261 9999
    21 441 9261 9999
    21 441 9261 9999
    21 441 9261 9999
    21 441 9261 9999
    21 441 9261 9999
    21 441 9261 9999
    21 441 9261 9999
    21 441 9261 9999
    21 441 9261 9999
    21 441 9261 2005
    21 441 9261 9999
    21 441 9261 2010
    21 441 9261 9999
    21 441 9261 9999
    21 441 9261 9999
    21 441 9261 9999
    21 441 9261 9999
    21 441 9261 9999
    21 441 9261 9999
    21 441 9261 9999
    21 441 9261 9999
    21 441 9261 9999
    21 441 9261 9999
    21 441 9261 2010
    21 441 9261 9999
    21 441 9261 9999
    21 441 9261 9999
    21 441 9261 9999
    21 441 9261 9999
    21 441 9261 9999
    21 441 9261 9999
    21 441 9261 9999
    21 441 9261 9999
    21 441 9261 9999
    21 441 9261 9999
    21 441 9261 9999
    21 441 9261 9999
    21 441 9261 9999
    21 441 9261 9999
    21 441 9261 9999
    21 441 9261 9999
    21 441 9261 9999
    21 441 9261 9999
    21 441 9261 9999
    21 441 9261 9999
    21 441 9261 9999
    21 441 9261 9999
    21 441 9261 2010
    21 441 9261 9999
    21 441 9261 9999
    21 441 9261 9999
    21 441 9261 9999
    21 441 9261 9999
    21 441 9261 9999
    21 441 9261 9999
    21 441 9261 9999
    21 441 9261 9999
    21 441 9261 9999
    21 441 9261 9999
    21 441 9261 9999
    21 441 9261 9999
    21 441 9261 9999
    21 441 9261 9999
    21 441 9261 9999
    21 441 9261 9999
    21 441 9261 2000
    21 441 9261 9999
    21 441 9261 9999
    21 441 9261 9999
    21 441 9261 9999
    end
    label values bb03a BB03AD

  • #2
    Code:
    svy: margins, at(bb03a=41 arrival)
    But the output says, last estimates not found...
    Why are you typing the prefix svy before margins?
    Best regards,

    Marcos

    Comment


    • #3
      Because I have survey data, which I have weighted before with:
      Code:
      svyset [pweight = ixpxh]
      As I am still learning Stata, I thought of reading once, that if I use survey data, each command should have the prefix svy. But it looks like I read it wrong then.

      Comment


      • #4
        No problem if you feel you are "still learning" Stata.

        I am sure (say, two-tailed p value < 0.05, no overlapping CIs, power = 90%, random sampling, of course) that the majority of this Forum members, even the most stellar ones, even those who keep dealing with Stata on a daily basis for a couple of decades, well, believe me, these hard-core guys previously avowed that they consider themselves as "still learning".

        This remark being made, please type - help svy postestimation - in the Command Window, then read the example 3.

        Hopefully that helps.
        Last edited by Marcos Almeida; 06 Nov 2018, 11:51.
        Best regards,

        Marcos

        Comment


        • #5
          Thank you, Sir. However If I use this:
          margins arrival, vce(unconditional) at(bb03a=41)
          I got the output:
          Code:
          margins arrival, vce(unconditional) at(bb03a=41)
          
          Predictive margins                              Number of obs     =    10,726
          Subpop. no. obs   =    10,725
          
          Expression   : Linear prediction, predict()
          at           : bb03a           =          41
          
              
          Linearized
          Margin   Std. Err.      t    P>t     [95% Conf.    Interval]
              
          arrival
          0            .  (not estimable)
          1980            .  (not estimable)
          1985            .  (not estimable)
          1990            .  (not estimable)
          1995            .  (not estimable)
          2000            .  (not estimable)
          9999     3.742419   .0184985   202.31   0.000     3.706159    3.77868

          Comment


          • #6
            Sorry, the commands in example 3 are slightly different from the one you typed.

            What is more, with regards to the model, specifically, I believe I cannot be of much help, and this is for a couple of reasons: the field of expertise is far from mine; the use of squared and cubic terms, if necessary, could be simplified by using the appropriate notation; the (automatic) omission of these terms (in the regression analysis) posed doubts concerning the necessity of them in the model, let alone the potential (lack of ) improvement; I didn't understand why "arrival" is 9999, I mean, it seems not to be a code, neither a date; getting margins at a specific value, here, one which is not presented in the shared data, might lead to estimations issues; the data you shared seem to have less variables than the ones in the output; svyset was not shown. This is the furtherst I can go. Hopefully you'll get more information | help.
            Best regards,

            Marcos

            Comment


            • #7
              Sorry Sir, I was not clear about my variables. Arrival is coded as 0, 1980, 1985, 1990, 1995, 2000, 2005, 2010 and 9999. 0 represents immigrant cohort arrival before 1980, 1980 represents immigrants arrival from 1980 to 1984 and so on. 9999 represents natives, I took 9999 for natives just randomly, since I used already 0 for the immigrants arrival before 1980. Since I used for the variable arrival (categorical variable) 9999 as the reference group, I am analyzing the immigrants arrival cohort relative to that of natives. This was the first code

              Code:
               
                svy: regress lnhourlyw_w i.ib9999.arrival if year==2004
              However, since I am not controlling for age in that regression, I would like to have age-adjusted wage differential of immigrant to native. Using third polynomial age should allow for non-linear relationship (bb03a represents age). Therefore, I have used the following code:

              Code:
               
               svy: regress lnhourlyw_w bb03a bb03a2 bb03a3 c.bb03a##i.ib9999.arrival c.bb03a2##i.ib9999.ar > rival c.bb03a3##i.ib9999.arrival  i.ib9999.arrival if year==2004
              Since, I am interest on the effects the immigrant cohorts, I would like to have estimates at the mean age (for year 2004, mean age =41).

              Hope, I could formulate it a bit more clearer.

              Comment


              • #8
                It seems unclear maybe what I am asking. In short, I have a multiple regression (age is also a variable in that regression). Now I would like to have the model evaluated at the age of 40. I was thinking on using the command predict. However, predict does not allow to use option at().

                Comment


                • #9
                  Hi Anshul,

                  I am not sure what exactly you re trying to do, but it seems related to the following regression trick:

                  Say I have fitted the following regression of wages on age and age^2 (E is the expectation operator):

                  (1) Ew = a + b*age + c*age^2.

                  The marginal effect here is

                  (2) (d Ew)/(d age) = b + c*age.

                  Therefore the marginal effect depends on age, as age entered non-linearly the original regression. Note also that the marginal effect is

                  (d Ew)/(d age) = b, when evaluated at age=0.

                  To have the marginal effect evaluated at 40, you do generate age*=age - 40, and you fit the original regression in eq(1) however using age* instead of age. Then the marginal effect from eq(2) evaluated at 40 will be simply again (d Ew)/(d age) = b. If you want to have the marginal effect evaluated at the sample mean of age, you fit the regression using age*= age - mean(age), then your marginal effect evaluated at the mean will be simply b.

                  Comment


                  • #10
                    Hey Joro,

                    What I am exactly doing is this: I have a wage regression which should measure the relative wage of immigrant relative to native. In that regression, I am considering the cohort effects, so I am splitting immigrant population into immigrant arrival waves. This is my first regression which has the aim to show that considering different cohort is important if we want talk about immigrant-native wages. However, this regression is not a age-adjusted wage differential. Therefore I am additionally including a third polynomial of age in that regression where I am regressing immigrant arrival relative to native on log wages. Now I would like to see the effects of immigrant arrival evaluated on the mean age of the population.

                    I will try your trick, thanks for the support!!

                    Comment


                    • #11
                      Sorry, I am not sure if this is what I exactly need. I try it again with more information. Please dont read my earlier posts.

                      I am regressing log wages on immigrant dummy. Basically, I want to know the wage differential between natives and immigrants.

                      Now, I have splitted the immigrant population into immigrant cohort. So my regression looks like this for the year 2004 which compares log wages
                      of immigrant cohort to that of natives I do this also for the year 2009 and 2014 (only for 2004 displayed here):
                      Code:
                      svy: regress lnhourlyw_w i.ib9999.arrival if year==2004
                      (running regress on estimation sample)
                      
                      Survey: Linear regression
                      
                      Number of strata   =         1                  Number of obs     =    10,726
                      Number of PSUs     =    10,726                  Population size   =    1,317,293
                      Design df         =    10,725
                      F(   6,  10720)   =    99.52
                      Prob > F          =    0.0000
                      R-squared         =    0.0279
                      
                          
                      Linearized
                      lnhourlyw_w       Coef.   Std. Err.      t    P>t     [95% Conf.    Interval]
                          
                      arrival
                      pre 1980    -.1686351   .0151419   -11.14   0.000     -.198316    -.1389543
                      1980-84    -.1678049   .0202635    -8.28   0.000     -.207525    -.1280847
                      1985-89    -.2158353   .0165672   -13.03   0.000    -.2483101    -.1833604
                      1990-94    -.2542113   .0122076   -20.82   0.000    -.2781405    -.2302822
                      1995-99    -.1508089   .0222109    -6.79   0.000    -.1943463    -.1072715
                      2000-04    -.0889885   .0228124    -3.90   0.000     -.133705    -.044272
                      
                      _cons    3.689774   .0057737   639.07   0.000     3.678457    3.701092
                      The paper I am using as reference for this analysis does in a second step look at the age-adjusted wage differential. It says: The age-adjusted wage
                      differential are calculated from a regression estimated in each census cross-section (in my case: 2004, 2009, 2014) which includes an intercept and
                      a third-order polynomial in the worker's age and interacts all variables with an immigrant dummy. The log wage differentials are then evaluated at the
                      age of 40
                      . In my case, the regression for this second step is:

                      Code:
                      svy: regress lnhourlyw_w age age2 age3    foreign    foreign2 foreign3 i.ib9999.arrival    if    year==2
                      > 004
                      (running regress on estimation sample)
                      
                      Survey: Linear regression
                      
                      Number of strata   =         1        Number of obs     =     10,726
                      Number of PSUs     =    10,726        Population size   =  1,317,293
                              Design df         =     10,725
                              F(  12,  10714)   =     244.61
                              Prob > F          =     0.0000
                              R-squared         =     0.2189
                      
                              
                      Linearized
                      lnhourlyw_w       Coef.   Std. Err.    t    P>t     [95% Conf. Interval]
                              
                      age    .1339665   .0152074    8.81    0.000     .1041572    .1637757
                      age2   -.0022769      .0004    -5.69    0.000    -.0030609    -.001493
                      age3    .1261596    .033307    3.79    0.000     .0608718    .1914474
                      foreign    .1088957   .0338962    3.21    0.001     .0424529    .1753385
                      foreign2   -.0024298   .0008359    -2.91    0.004    -.0040683   -.0007913
                      foreign3    .1797601   .0657533    2.73    0.006     .0508716    .3086487
                      
                      arrival
                      pre 1980    -1.962534   .4349641    -4.51    0.000    -2.815144   -1.109924
                      1980-84    -1.930812   .4371311    -4.42    0.000    -2.787669   -1.073954
                      1985-89    -1.942779   .4417473    -4.40    0.000    -2.808686   -1.076872
                      1990-94    -1.943912   .4435777    -4.38    0.000    -2.813407   -1.074418
                      1995-99    -1.743931   .4441677    -3.93    0.000    -2.614582   -.8732798
                      2000-04    -1.600682   .4372272    -3.66    0.000    -2.457728   -.7436355
                      
                      _cons    1.260013   .1825067    6.90    0.000     .9022659     1.61776
                      The foreign, foreign2 and foreign3 are calculated as following, where immigrant is dummy (1 for immigrant, 0 for native):
                      Code:
                      gen foreign=immigrant*age
                      gen foreign2=immigrant*age2
                      gen foreign3=immigrant*age3
                      My question is, how can I evaluate the second regression at the age of 40? I hope I could write it more clear (sorry since my English is not so good).
                      In the attachment, I upload the table of regression from the paper. There we can see the effects evaluated at the age of 40.

                      I thought of using the command predict. However, there I can't use the option at().
                      Attached Files

                      Comment


                      • #12
                        would the following method work (40 is the mean age)?
                        Code:
                        margins, dydx(arrival) at(age=(40))
                        
                        Average marginal effects                        Number of obs     =     10,726
                        Subpop. no. obs   =     10,725
                        Model VCE    : Linearized
                        
                        Expression   : Linear prediction, predict()
                        dy/dx w.r.t. : 0.arrival 1980.arrival 1985.arrival 1990.arrival 1995.arrival 2000.arrival
                        at           : age             =          40
                        
                        
                        Delta-method
                        dy/dx   Std. Err.      t    P>t     [95% Conf. Interval]
                        
                        arrival
                        pre 1980    -1.962534   .4349641    -4.51   0.000    -2.815144   -1.109924
                        1980-84    -1.930812   .4371311    -4.42   0.000    -2.787669   -1.073954
                        1985-89    -1.942779   .4417473    -4.40   0.000    -2.808686   -1.076872
                        1990-94    -1.943912   .4435777    -4.38   0.000    -2.813407   -1.074418
                        1995-99    -1.743931   .4441677    -3.93   0.000    -2.614582   -.8732798
                        2000-04    -1.600682   .4372272    -3.66   0.000    -2.457728   -.7436355
                        
                        Note: dy/dx for factor levels is the discrete change from the base level

                        Comment


                        • #13
                          would the following method work (40 is the mean age)?
                          It would, except that your regression was not done properly for the purpose of using -margins- afterward. Your polynomial terms and interactions were not done using factor-variable notation, so -margins- has no way of knowing that age2 means age^2 and age3 means age^3. It also has no way to know that foreign, foreign2 and foreign3 are the interactions between immigrant status and age, age^2, and age^3, respectively. Consequently the results you got from -margins- are incorrect.

                          But you are on the right track now. So the thing to do is re-do the regression properly.

                          Code:
                          svy: regress lnhourlyw_w i.foreign##c.age##c.age##c.age   ib9999.arrival if year==2004
                          After that,-margins arrival, at(age = (40))- will give you the expected values of lnhourlyw_w at age 40 in each category of arrival. Your own margins command in #12 is written to calculate the marginal effects of arrival in each category instead. Maybe that is what you mean by log wage differential?" Perhaps that is what you want.

                          Comment


                          • #14
                            I have taken your advise with respect to using factor-variable notation.
                            Code:
                            svy: regress lnhourlyw_w c.age c.age#c.age c.age#c.age#c.age  i.is051#c.age i.is051#c.age#c.
                            > age i.is051#c.age#c.age#c.age i.ib9999.arrival if year==2004
                            (running regress on estimation sample)
                            
                            Survey: Linear regression
                            
                            Number of strata   =         1                  Number of obs     =     10,726
                            Number of PSUs     =    10,726                  Population size   =  1,317,293
                            Design df         =     10,725
                            F(  12,  10714)   =     244.61
                            Prob > F          =     0.0000
                            R-squared         =     0.2189
                            
                            
                            Linearized
                            lnhourlyw_w       Coef.   Std. Err.      t    P>t     [95% Conf. Interval]
                            
                            age    .1339664   .0152074     8.81   0.000     .1041572    .1637757
                            
                            c.age#c.age   -.0022769      .0004    -5.69   0.000    -.0030609    -.001493
                            
                            c.age#c.age#c.age    .0000126   3.33e-06     3.79   0.000     6.09e-06    .0000191
                            
                            is051#c.age
                            foreign     .1088956   .0338962     3.21   0.001     .0424528    .1753384
                            
                            is051#c.age#c.age
                            foreign    -.0024298   .0008359    -2.91   0.004    -.0040683   -.0007913
                            
                            is051#c.age#c.age#c.age
                            foreign      .000018   6.58e-06     2.73   0.006     5.09e-06    .0000309
                            
                            arrival
                            pre 1980    -1.962532    .434964    -4.51   0.000    -2.815142   -1.109922
                            1980-84     -1.93081   .4371309    -4.42   0.000    -2.787668   -1.073952
                            1985-89    -1.942777   .4417472    -4.40   0.000    -2.808684   -1.076871
                            1990-94    -1.943911   .4435775    -4.38   0.000    -2.813405   -1.074417
                            1995-99    -1.743929   .4441675    -3.93   0.000     -2.61458   -.8732785
                            2000-04     -1.60068    .437227    -3.66   0.000    -2.457726   -.7436342
                            
                            _cons    1.260013   .1825066     6.90   0.000     .9022663     1.61776
                            Now using -margins, dydx(arrival) at(age=(40)), I get:

                            Code:
                            margins, dydx(arrival) at(age=(40))
                            
                            Average marginal effects                        Number of obs     =     10,726
                            Subpop. no. obs   =     10,725
                            Model VCE    : Linearized
                            
                            Expression   : Linear prediction, predict()
                            dy/dx w.r.t. : 0.arrival 1980.arrival 1985.arrival 1990.arrival 1995.arrival 2000.arrival
                            at           : age             =          40
                            
                            
                            Delta-method
                            dy/dx   Std. Err.      t    P>t     [95% Conf. Interval]
                            
                            arrival
                            pre 1980    -1.962532    .434964    -4.51   0.000    -2.815142   -1.109922
                            1980-84     -1.93081   .4371309    -4.42   0.000    -2.787668   -1.073952
                            1985-89    -1.942777   .4417472    -4.40   0.000    -2.808684   -1.076871
                            1990-94    -1.943911   .4435775    -4.38   0.000    -2.813405   -1.074417
                            1995-99    -1.743929   .4441675    -3.93   0.000     -2.61458   -.8732785
                            2000-04     -1.60068    .437227    -3.66   0.000    -2.457726   -.7436342
                            
                            Note: dy/dx for factor levels is the discrete change from the base level.
                            So, the coefficients on arrival remains same, therefore I guess this is not the margins code I am searching.

                            However, If I use -margins arrival, at(age = (40))-, I get:

                            Code:
                            margins arrival, at(age=(40))
                            
                            Predictive margins    Number of obs     =    10,726
                                Subpop. no. obs   =    10,725
                            Model VCE    : Linearized
                            
                            Expression   : Linear prediction, predict()
                            at           : age             =          40
                            
                                    
                            Delta-method
                            Margin   Std. Err.      t    P>t     [95% Conf.    Interval]
                                    
                            arrival
                            pre 1980     2.116585   .3538278     5.98    0.000     1.423017    2.810153
                            1980-84     2.148307   .3558714     6.04    0.000     1.450733    2.845881
                            1985-89      2.13634   .3604157     5.93    0.000     1.429858    2.842821
                            1990-94     2.135206   .3622118     5.89    0.000     1.425204    2.845209
                            1995-99     2.335188   .3629064     6.43    0.000     1.623824    3.046551
                            2000-04     2.478437   .3560442     6.96    0.000     1.780524    3.176349
                            9999     4.079117   .0816198    49.98    0.000     3.919127    4.239107
                            Now, is it possible from this output to test, whether the difference of lnhourlyw_w for the arrival (e.g. 1990-94) to natives (9999) is significant? I think I am looking for this because this would show me the difference of log wages between immigrant cohorts and natives evaluated at age=40.

                            Comment


                            • #15
                              Code:
                              margins arrival, at(age = (40)) pwcompare

                              Comment

                              Working...
                              X