Announcement

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

  • Generating a variable interacting two variables

    I',m doing a university homework and I'm stuck with the next problem. I have four principal variables call YEARs (indicate how old is each person), BMI (body mass index of each person), COUNTRY (dummy, 0 por local people, 1 for foreign), anda YOR (year of residence for foreign). I want to watch if there is any effect in the years of residence, not only in foreing, but also in local people, so for local I'm using years as years of residence.In stata I typed the next commands:

    gen COUNTRY2= (1-COUNTRY)
    gen YOR_LOCALS = YEARS if COUNTRY == 0
    gen CNTRY2xYORLOC = COUNTRY2 * YOR_LOCALS
    reg IMC (adjustements variables) COUNTRY2 YOR CNTRY2xYORLOC YEARS

    So I want to see:
    B of years: effect of years in IMC
    B of COUNTRY2: the constant difference between those born outside and those born inside. B of YOR: effect of years of residence on those not born in Spain.
    B of CNTRY2xYORLOC: difference in the coefficient of years of residence between those born outside and those born inside

    But every time I mix YOR with the interaction variable the fail error "no observations" appears. Any solution?

  • #2
    It is the policy of this Forum that we do not provide help with homework assignments. For that you should seek help from your instructor, teaching assistant, or, if consistent with your school's policy, your fellow students. (To be clear, assistance with problems arising in the course of thesis and dissertation projects is available here.)

    That said, you asked essentially the same question yesterday at https://www.statalist.org/forums/for...inear-reg-mode and received an answer there at #2, which you appear to have ignored. While there may be other difficulties, the approach suggested there would almost surely avoid this particular problem.

    Comment


    • #3

      I apologize for that. I still don't understand statalist very well and I hadn't seen the second message I just reviewed. I think I've already gotten what I was looking for. Thank you very much and sorry for the inconvenience.

      Comment

      Working...
      X