Announcement

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

  • Variance decomposition: between, within-between, within

    Hi all,

    I am relatively noob at Stata and I am trying to construct variance decomposition of wages. I understand that if I use the command areg (or xtreg) y, abs(groupvar) I can obtain the within and the between components of my variance.
    I wish to push my variance decomposition a little further: I want to decompose the variance of wage according to three components: across firms, within firms across occupations and within occupations.
    Assuming I have enough observations at each level, is there a clever way to do this?

    Thank you so much for your help.

    Mathilde

  • #2
    You didn't get a quick answer. You'll increase your chances of a useful answer by following the FAQ on asking questions - provide Stata code in code delimiters, readable Stata output, and sample data using dataex.

    You might look at refhdfe.

    Comment


    • #3
      Thanks! Sorry so here is the code I have so far:

      Code:
      gen lwage = log(wage)
      
      ** Fixed-effect regressions
      * Over the whole sample
          egen lw_var = sd(lwage)
          replace lw_var = lw_var^2
      
      * Within/Between firms
          reghdfe lwage, abs(firmid, savefe)
          predict fwithin if e(sample), res
          predict fbetween if e(sample), xbd
          egen temp=sd(fbetween)
          gen sfbetween = temp*temp
          drop temp
          egen temp=sd(fwithin)
          gen sfwithin = temp*temp
          drop temp
          gen sftotal = sfwithin + sfbetween
      
      sum lw_var sftotal sfwithin sfbetween
      
      * Within/Between firm-occupation, interacted (i.e. underlying assumpyion is that the occupation fixed-effect varies across firms)
          reghdfe lwage, abs(firmid#occ, savefe)
          predict fowithin if e(sample), res
          predict fobetween if e(sample), xbd
          egen temp=sd(fobetween)
          gen sfobetween = temp*temp
          drop temp
          egen temp=sd(fowithin)
          gen sfowithin = temp*temp
          drop temp
          gen sfototal = sfowithin + sfobetween
      
      sum sfototal sfowithin sfobetween
      I am using StataSE 14.

      My issue is that I don't know how to reconcile the two within/between decompositions. I obtain the same total variance in both case, which is normal, but what I would really like is use the variance obtain in sfwithin, and from there decompose in a within/between component across occupation.
      Could I just do something like:

      Code:
      * Within/between occupations in a given firm
         reghdfe sfwithin, absorb(occ, savefe)
         predict fowithin if e(sample), res
         predict fobetween if e(sample), xbd
      or would that not make any sense?

      Thank you very much.
      Last edited by mathilde le moigne; 15 Jun 2018, 01:50.

      Comment

      Working...
      X