Graphics Reference
In-Depth Information
twoway (
scatter
propval100 popden) (
lfit
propval100 popden)
Stata allows us to overlay
twoway
graphs. In this case, we make a classic
plot showing a scatterplot overlaid with
a fit line using the
scatter
and
lfit
commands. For more details about
overlaying graphs, see
Twoway : Overlaying
(87).
Uses allstates.dta & scheme vg s2c
0
2000
4000
6000
8000
10000
Pop/10 sq. miles
% homes cost $100K+
Fitted values
twoway (
scatter
propval100 popden) (
lfit
propval100 popden)
(
qfit
propval100 popden)
The ability to combine
twoway
plots is
not limited to just overlaying two plots;
we can overlay multiple plots. Here, we
overlay a scatterplot with a linear fit
line (
lfit
) and a quadratic fit line
(
qfit
).
Uses allstates.dta & scheme vg s2c
0
2000
4000
6000
8000
10000
Pop/10 sq. miles
% homes cost $100K+
Fitted values
Fitted values
twoway (scatter propval100 popden) (
mspline
propval100 popden)
(
fpfit
propval100 popden) (
mband
propval100 popden)
(
lowess
propval100 popden)
Stata has other kinds of fit methods in
addition to linear and quadratic fits.
This example includes a median spline
(
mspline
), fractional polynomial fit
(
fpfit
), median band (
mband
), and
lowess (
lowess
). For more details, see
Twoway : Fit
(49).
Uses allstates.dta & scheme vg s2c
0
2000
4000
6000
8000
10000
Pop/10 sq. miles
% homes cost $100K+
Median spline
predicted propval100
Median bands
lowess propval100 popden
The electronic form of this topic is solely for direct use at UCLA and only by faculty, students, and staff of UCLA.