Graphing Scatterplots in Stata
One way to look at the relationship between two variables is using a scatterplot. For the most basic scatterplot, the command is simply
scatter [x variable] [y variable].
You also might want to create a scatterplot with a regression line. The command for this is
twoway lfit [dependent variable] [independent
variable] || scatter [dependent variable] [independent variable] The first part of the command draws a regression line, regressing the specified [dept variable] over the specified [indep variable]. The || is the equivalent of saying "and" -- what comes after the double bar tells Stata to also draw a scatterplot on the same axes. The end result is a scatterplot with a regression line.
To obtain the equation for this line, the command is
regress [dept variable] [indept variable(s)]
To draw separate scatterplots for groups within your data, e.g. for males and females, you would add a by() suffix e.g.,
scatter health age,