Hello everyone,

I am modelling optimal marginal income tax rates. I use two models. One is very volatile for extremely high incomes, which is why I use a second model which works only for very high incomes. To compute my final marginal tax rates, I need to merge the results of the two models based on where they intersect for high incomes. I know this is always the second time they intersect. The image below shows an example of the situation:
Array

Variables are mtr and mtrh

Essentially, I want Stata to find where the two variables intersect for the second time. Then, have Stata generate a new variable which equals mtr for all levels of income below the intersection, and the then equal the rate of the intersection (constant) for the high levels of income.
I could easily do this manually, but since I want to simulate this endless times using different income distributions, I would much rather have Stata do it for me.
If I could get Stata to return the level of income for which mtr and mtrh intersect for the second time, I would be able to generate the desired variable easily. Can anyone help me with this?

Kind regards,

Patrick Lambertus