Announcement

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

  • tabulate, gen() for interactions

    Dear all,

    I am going to generate - i.region#i.per-- with tab, gen()
    I know:
    Code:
    tab region, gen(d_re)
    tab per, gen(d_p)
    how about -- i.region#i.per ?
    of course I can do it manually: d_re1#d_p1 d_re2#d_p1....
    but it takes ages (there are pretty much)

    Is there any shortcut?
    Code:
    input float region byte per
    2 0
    2 0
    2 1
    2 2
    2 2
    5 0
    5 0
    5 1
    5 1
    5 2
    5 2
    5 3
    5 3
    5 4
    4 0
    4 0
    4 1
    4 1
    4 2
    4 2
    4 3
    4 3
    4 4
    5 0
    5 0
    1 0
    1 0
    1 1
    1 1
    1 2
    1 2
    1 3
    1 3
    1 4
    1 4
    1 5
    3 0
    3 0
    3 1
    3 1
    3 2
    3 0
    3 0
    3 1
    3 1
    3 2
    3 2
    3 3
    3 3
    3 4
    1 0
    1 0
    1 1
    1 1
    cheers,
    Paris

  • #2
    tabulate knows nothing about interactions. But you don't usually need to generate such variables any way. Using factor variable notation gets you what you need. The exceptions would be old community-contributed commands that don't support factor variable notation.

    Comment


    • #3
      Thank you Nick,
      Actually, I am going to run
      Code:
      xtivreg mig_jump S_firm_age S_foreign_aff   i.region#i.per i.sector#i.per (S_immi_sh S2_emplo_sh= S_impu_sh_origin S2_emplo_iv ) , fe first vce(robust)
      in this way because of collinearity results are wired beside that Stata eliminates those variables by itself. When I do it manually-- d_re1#d_p1 d_re2#d_p1.. I can choose which one to include/exclude based on the importance of the variables. for example, sector 1 is important and must be at the regression while 5 is not.
      I am seeking for a code to do it instead of doing it manually to avoid any typos (also I am a bit lazy ).


      Comment

      Working...
      X