Hi all,
I am trying to split the independent variable into different ranges and then regress the dependent variable on those separate ranges in one regression. The regression output will have different slopes for each range.
To explain simply, I am trying to replicate
in a single regression command. I understand lfit is plotting predicted values but in my regression output I want slopes of individual ranges.
For this I created,
where X1, X2, X3 are the starting points in the respective ranges.
And then ran the regression
I am not sure if this is correct. Can we specify ranges inside the regression command for example by using "if inrange()" multiple times or in any other way?
Any help is much appreciated. Thank you.
I am trying to split the independent variable into different ranges and then regress the dependent variable on those separate ranges in one regression. The regression output will have different slopes for each range.
To explain simply, I am trying to replicate
Code:
twoway (lfit Y Range1) || (lfit Y Range2) || (lfit Y Range3)
For this I created,
Code:
egen range = cut(X), at(X1, X2, X3) icodes
And then ran the regression
Code:
reg Y i.range
Any help is much appreciated. Thank you.

Comment