Fred Wolfe <[email protected]>
> I have noticed that
>
> . lpoly depnow haq_ if dxn == 1, noscat ci addplot(lpoly depnow haq_
> if dxn == 4, ci)
> option ci not allowed
> r(198);
> Produces an error, but
>
> . lpoly depnow haq_ if dxn == 1, noscat ci addplot(lpoly depnow haq_ if dxn ==4)
>
> does not.
>
> If run without the options, scatter is suppressed, but the CIs are
> not drawn for the addplot graph.
Fred is thinking that the option -addplot()- allows us to stack up and graph
the results from any graphics command, but -addplot()- is not that smart.
Option -addplot()- allows us to add -twoway- plots to the graphs of commands
that support it.
The subtle thing here is that in addition to the command -lpoly- there is a
twoway plot for local polynomial smooths, and that plot is also named -lpoly-.
The -lpoly- command supports the -ci- option to add confidence intervals
(CIs), but the -twoway lpoly- plot does not. A plot that does support CIs for
local polynomial smooths is -lpolyci-. Because of the complexity of parsing
-twoway- commands with potentially overlayed plots, it is always the plottype
itself that designates how many things will be plotted -- in this case both a
smoothed line and its CI.
Instead of typing, the illegal
. lpoly depnow haq_ if dxn == 1, noscat ci
addplot(lpoly depnow haq_ if dxn == 4, ci)
^^^^^ ^^
Fred can type
. lpoly depnow haq_ if dxn == 1, noscat ci
addplot(lpolyci depnow haq_ if dxn == 4)
^^^^^^^
I can't tell if Fred does or does not want the original scatters plotted. If
so, he can just keep adding twoway plots in his -addplot()- option, e.g.,
. lpoly depnow haq_ if dxn == 1, noscat ci
addplot(lpolyci depnow haq_ if dxn==4 || scatter depnow haq_ if dxn==4)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
This can be taken a long way, but for ultimate flexibility Fred might
consider using multiple -lpoly- commands with the options
-generate(x_var, smooth_var)- and -se(se_var)- to create variables containing
the resulting smooths and their standard errors (from which the CIs can be
calculated). Fred can then use the variables in a -twoway- command to produce
any combination of smooths and CIs that he likes.
-- Vince
[email protected]
*
* For searches and help try:
* http://www.stata.com/help.cgi?search
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/