I am trying to create inequity aversion variables in Stata. I have a panel dataset comprised of 10,000 individuals over 8 years. Say that wi is the individual's wage and wk is everyone else's wages in the person's comparison group (people in the same comparison group are the same age and gender), what I need is a variable (let's call it "upward comparison") equal to: [(1/n-1)Summation (wk-wi)] if wk>wi ("upward" because the person his comparing his/her wage to people with higher wages) and another variable (called "downward comparison") equal to [(1/n-1)Summation (wi-wk)] if wk<wi. I was thinking something along the lines of bysort year age gender personID: egen upward=mean(income-income[_n-1]) if income[_n-1]>income but it doesn't seem to work.
-
Login or Register
- Log in with
Comment