Graphics Reference
In-Depth Information
twoway (scatter propval100 urban) (lfit propval100 urban)
( qfit propval100 urban)
We can add a quadratic fit to the
previous graph by adding a qfit
command, so we can compare a linear
fit and quadratic fit to see if there are
nonlinearities in the fit. Note that the
legend does not clearly differentiate
between the linear and quadratic fit; we
will show you how to modify the legend
to label this more clearly below.
Uses allstates.dta & scheme vg teal
100
80
60
40
20
0
20
40
60
80
100
Percent urban 1990
% homes cost $100K+
Fitted values
Fitted values
twoway (scatter propval100 urban, msymbol(Oh) )
(lfit propval100 urban, clpattern(dash) )
(qfit propval100 urban, clwidth(thick) )
We add the msymbol(Oh) option to the
scatter command, placing it after the
comma, as it normally would be placed,
but before the closing parenthesis that
indicates the end of the scatter
command. We also add the
clpattern(dash) option to the lfit
command to make the line dashed and
add the clwidth(thick) option to the
qfit command to make the line thick.
Uses allstates.dta & scheme vg teal
100
80
60
40
20
0
20
40
60
80
100
Percent urban 1990
% homes cost $100K+
Fitted values
Fitted values
twoway (scatter propval100 urban) (lfit propval100 urban)
(qfit propval100 urban), legend(label(2 Linear Fit) label(3 Quad Fit))
While each graph subcommand can
have its own options, some options can
apply to the entire graph. As
illustrated here, we add a legend to the
graph to clarify the difference in the fit
values, and this option appears
following a comma after the closing
parenthesis following the qfit
command. The legend() option
appears at the end of the command
since it applies to the entire graph.
Uses allstates.dta & scheme vg teal
100
80
60
40
20
0
20
40
60
80
100
Percent urban 1990
% homes cost $100K+
Linear Fit
Quad Fit
The electronic form of this topic is solely for direct use at UCLA and only by faculty, students, and staff of UCLA.
Search WWH ::




Custom Search