# Re: st: Plotting a Local Polynomial Regression with CIs Accounting for Clustering

 From L S To statalist@hsphsun2.harvard.edu Subject Re: st: Plotting a Local Polynomial Regression with CIs Accounting for Clustering Date Sat, 28 Nov 2009 11:12:47 -0600

```That is great, thank you.

The one thing that I need to do is to exclude the dots from the
picture (I want the fractional polynomial regression and the extra
line, but I don't want individual observations shown in the graph, as
in my real data there are too many observations and they will clutter
up the picture).

Currently I am doing:

fracpoly reg y x, cluster(id)

But it would be great if there were a 'nodots' option (I did not see
any options that would seem to help with this)

Thanks again.

On Sat, Nov 28, 2009 at 4:46 AM, Maarten buis <maartenbuis@yahoo.co.uk> wrote:
> --- On Sat, 28/11/09, L S <lts40301@gmail.com> wrote:
>> I would like to graph a nonparametric regression of y on
>> x.  The graph should include 95% confidence intervals for
>> the nonparametric regression which account for clustering
>> of the errors over each individual in the data
>
> What about (you can add more graphs to this plot using the
>
> *----------------- begin example -----------------
> clear
> set obs 100
> set seed 1234
> gen id = _n
> gen e = uniform()
> expand 5
> gen x = uniform()
> gen y = -.6 + 1.4*x^.5 + .5*(x>.5) + e
> fracpoly reg y x, cluster(id)
> fracplot
> *------------------ end example ------------------
>
> Hope this helps,
> Maarten
>
> --------------------------
> Maarten L. Buis
> Institut fuer Soziologie
> Universitaet Tuebingen
> Wilhelmstrasse 36
> 72074 Tuebingen
> Germany
>
> http://www.maartenbuis.nl
> --------------------------
>
>
>
>
> *
> *   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/
>

Hello,

I would like to graph a nonparametric regression of y on x.  The graph
should include 95% confidence intervals for the nonparametric
regression which account for clustering of the errors over each
individual in the data (as well as plotting an extra unrelated line).

Here is some code:

clear
set obs 100
set seed 1234
gen id = _n
gen e = uniform()
expand 5
gen x = uniform()
gen y = -.6 + 1.4*x + e
twoway (lpolyci y x) (line x x)

This is what I want, except that I want the drawn 95% confidence
intervals to account for clustering of the error within individuals.
That is, I would love to be able to run code like

twoway (lpolyci y x, cluster(id)) (line x x)

but Stata does not like this.

The pictures are to qualitatively illustrate a point, so I am not
wedded to the local polynomial regression, and thus would be fine with
other types of nonparametric regression (someone mentioned Fan
regression to me) if the graph I want can be implemented with
confidence bounds accounting for clustering in Stata.

*
*   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/
```