Lines of best fit in Stata

May 22, 2019

In a another post we talked about scatter plots and the possibility of overlaying multiple types of plots on top of eachother. This is achieved by way of using the twoway command. In addition, for this example we will make use the linear fit graph to further illustrate the relationship between variables. Let’s use the same data as used in the previous example.

sysuse nlsw88, clear twoway (scatter wage grade) (lfit wage grade)

Scatter plot with linear fit overlay

Obviously in this case the positive relationship was quite clear already with the scatter plot, but in any case that relationships is visually even clearer now with the linear fit stacked on top.


Profile picture

Written by Johan Osterberg who lives and works in Gothenburg, Sweden as a developer specialized in e-commerce. Connect with me on Linkedin

2024 © Johan Osterberg