[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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

 From "Carlo Lazzaro" To Subject R: st: Plotting a Local Polynomial Regression with CIs Accounting for Clustering Date Tue, 1 Dec 2009 09:33:52 +0100

```For a comprehensive coverage of this and related topics, L S might want to
take a look at:

Royston P, Sauerbrei W. Multivariable Model-building. Chichester: Wiley,
2008.

Kind Regards,
Carlo
-----Messaggio originale-----
Da: owner-statalist@hsphsun2.harvard.edu
[mailto:owner-statalist@hsphsun2.harvard.edu] Per conto di L S
Inviato: martedì 1 dicembre 2009 2.37
A: statalist@hsphsun2.harvard.edu
Oggetto: Re: st: Plotting a Local Polynomial Regression with CIs Accounting
for Clustering

Thanks for your help.  And sorry for one more email.

I've been playing around with the fracpoly graphs for a couple days
now.  Compared to the local polynomial regression lines, they do not
look quite right.  The main thing is that the picture will depend
often depend fairly strongly on the number of degrees for the
fractional polynomial.  If you specify a number too small, the graph
will appear oversmoothed.  If you specify a number of degrees too
large, then the 95% CIs will often get very large.

fracpoly reg y x, cluster(id) degree(2)
fracplot, msymbol(none) addplot((function y=x))
fracpoly reg y x, cluster(id) degree(6)
fracplot, msymbol(none) addplot((function y=x))

In the toy data above this is not so bad, but it is more of an issue
with the real data.

I realize that choosing the degrees is a necesary choice.  It seems
though that lpoly (local polynomial) regression produces a graph for
my data that seems more reasonable.

Thus, though I said I was flexible with respect to which form of
nonparametric regression is used, I was wondering if there might be a
way to possibly return back to local polynomial regression or perhaps
another form of nonparametric regression (besides fracpoly) that will
allow me to plot 95% CIs accounting for clustering, e.g. something
like

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

Thanks a lot.

On Sat, Nov 28, 2009 at 11:20 AM, Martin Weiss <martin.weiss1@gmx.de> wrote:
>
> <>
>
> *******
> fracplot, msymbol(none) addplot((function y=x))
> *******
>
>
> HTH
> Martin
>
> -----Original Message-----
> From: owner-statalist@hsphsun2.harvard.edu
> [mailto:owner-statalist@hsphsun2.harvard.edu] On Behalf Of L S
> Sent: Samstag, 28. November 2009 18:13
> To: statalist@hsphsun2.harvard.edu
> Subject: Re: st: Plotting a Local Polynomial Regression with CIs
Accounting
> for Clustering
>
> 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)
> fracplot, addplot(line x x)
>
> But it would be great if there were a 'nodots' option (I did not see
> any options that would seem to help with this)
>
> fracplot, nodots addplot(line x x)
>
> 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
>> -addplot()- option):
>>
>> *----------------- 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/
>
>
> *
> *   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/
>

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

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

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