I have used mkspline to estimate a regression, and want to graph the predicted value of the dependent variable as income varies. I did what seemed natural. Splined it in five sections -- using percentiles, so the knot points (inc1 through inc5) are at the 20th, 40th, etc. percentile of the sample's income distribution. I then tried " margins, at (inc1=(0 10000 20000 29835)) " which I believe gives average predicted value if everyone in the sample kept their other characteristics but income was fixed at the respective values (feel free to note any errors before I get to the question). The last value is the location of the first knot. Then I graphed this sucker using marginsplot. I then " margins, at (inc2=(29835 30000 etc.) and marginsplot for this segment.
Issue 1: the two lines do not produce the same margin at the first knot point (or any of the others). Using the top value for inc1, the depvar is predicted to be .006829, using the bottom value for inc2 the prediction is .1146 -- the two values are too far apart to be roundoff error. Doesn't mkspline produce linear segments that are continuous at each knot?
Issue 2 : If I solve issue 1, I'd like to combine the graphs into one graph where the vertical axis is the predicted depvar and the horizontal is income ranging across the splines. Is there an easy way to do that.
Thanks for reading this far, and I'll appreciate any help.
Issue 1: the two lines do not produce the same margin at the first knot point (or any of the others). Using the top value for inc1, the depvar is predicted to be .006829, using the bottom value for inc2 the prediction is .1146 -- the two values are too far apart to be roundoff error. Doesn't mkspline produce linear segments that are continuous at each knot?
Issue 2 : If I solve issue 1, I'd like to combine the graphs into one graph where the vertical axis is the predicted depvar and the horizontal is income ranging across the splines. Is there an easy way to do that.
Thanks for reading this far, and I'll appreciate any help.
Comment