Announcement

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

  • Regression analysis with controls that apply to only some observations

    Hi, all! I have browsed around but haven't found a direct answer to this question and hoped you could help. I'd like to run a regression using survey data on immigrants and native-born populations in the United States, with the native-born population as the reference group. I have information on the year that the immigrant respondents arrived in the country but, as native-born populations, the U.S.-born respondents do not have information there. Is there a way to run a regression that controls for "years since arrival" only for the immigrant respondents but not the U.S.-born ones?

  • #2
    I think you just replace yearsincearrival with 0 if native. since always zero, it doesn't have a coefficient to mess things up.

    Code:
    clear all
    set obs 1000
    egen year = seq(), from(2000) to(2020) block(50)
    g immigrant = runiform() > 0.8
    g arrival = int(runiform(2000, 2020)) * immigrant
    g yearsincearrival = year - arrival if immigrant
    replace yearsincearrival = 0 if yearsincearrival<-1 | mi(yearsincearrival)
    g x = rnormal()
    g y = 1 + 1*x*(~immigrant) + 2*x*immigrant + 0.5*yearsincearrival + rnormal()
    
    reg y x yearsincearrival if ~immigrant
    reg y x yearsincearrival if immigrant
    reg y x c.x#c.immigrant yearsincearrival

    Comment

    Working...
    X