[R] contour for plotting confidence interval on scatter plot of bivariate normal distribution

peter dalgaard pdalgd at gmail.com
Sat Mar 3 19:22:13 CET 2012

On Mar 3, 2012, at 17:01 , drflxms wrote:

> # this is the critical block, which I still do not comprehend in detail
> z <- array()
> for (i in 1:n){
>        z.x <- max(which(den$x < x[i]))
>        z.y <- max(which(den$y < y[i]))
>        z[i] <- den$z[z.x, z.y]
> }

As far as I can tell, the point is to get at density values corresponding to the values of (x,y) that you actually have in your sample, as opposed to den$z which is for an extended grid of all possible (x_i, y_j) combinations. 

It's unclear to me what happens if you look at quantiles for the entire den$z. I kind of suspect that it is some sort of approximate numerical integration, but maybe not of the right thing.... 

Re SD: Once you go into two dimensions, SD loses all meaning, and adding nonparametric density estimation into the mix doesn't help, so just stop thinking in those terms! 

Peter Dalgaard, Professor,
Center for Statistics, Copenhagen Business School
Solbjerg Plads 3, 2000 Frederiksberg, Denmark
Phone: (+45)38153501
Email: pd.mes at cbs.dk  Priv: PDalgd at gmail.com

More information about the R-help mailing list