Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: RE: How Do I Plot a Serset?

From   "Nick Cox" <>
To   <>
Subject   st: RE: How Do I Plot a Serset?
Date   Fri, 5 Sep 2003 10:37:53 +0100

Germán Rodríguez

> Roger Newson had a request for examples of using sersets,
> but I haven't
> yet seen any replies.  Like him, I read the documentation
> on sersets.
> The help file says they are used extensively by the
> graphics system and
> refers to the graphics manual. But the manual's index has
> no entry for
> sersets, and my browsing so far has yielded no results.
> My interest arose out of missing c(s), the spline option of
> connect in
> the old graphics system.  As far as I can see, the option
> is gone. (I
> know I can use gr7, but that misses the point.) The option was nice
> because one could evaluate a log-likelihood function of a scalar
> parameter at half-a-dozen points, and then plot a nice
> smooth curve with
> just a few keystrokes.
> Looking at sersets I discovered a promising command, serset
> create_cspline, which seems to compute everything one would
> need to do
> spline interpolation. I managed to turn my y and x variables into a
> serset, and then used serset create_cspline y x to
> interpolate with a
> default of five points between pairs of x's, which is most
> excellent.
> But how do I plot the serset? Could we pretty please have an example
> showing how to do a line plot of y and x from a
> user-defined serset?  Of
> course it would be even nicer if someone created a spline
> connectstyle,
> so we could go back to using c(s). Dare I ask?

A couple of comments, which leave the main question

1. The main documentation at present for -serset- appears
to be [P] serset, not in [G].

2. -c(s)- has not been removed, but has a new identity
as -twoway mspline-. It remains very useful. What is
more awkward than it used to be is smoothing several
things at once, as -twoway mspline- takes only one
y variable, but would seem fine for the log-likelihood

I suspect what is behind this move is logic.
-c(s)- is not a purely presentational detail like
(in similar oldspeak) say -c(l)- or -c(J)-. The
computation of cross-medians and the cubic spline
interpolation bring in some data analysis. It really
belongs in a room of its own, just as -lowess- does.

Naturally, for multiple y, you could go

twoway mspline y1 x || mspline y2 x || ... || mspline
yp x

but sometimes the spirit is willing, but the flesh
is weak, at the thought at typing out the specification
and of cleaning up the legend (which in this case gives
"Median spline" again and again ... and again).

Germán's question reminds me that I have several
times wanted to do something like this,
so I'll look into writing a wrapper program.


*   For searches and help try:

© Copyright 1996–2021 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index