Statalist


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

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


From   L S <[email protected]>
To   [email protected]
Subject   st: Plotting a Local Polynomial Regression with CIs Accounting for Clustering
Date   Fri, 27 Nov 2009 19:09:05 -0600

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.

Thanks a lot.
*
*   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–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index