[R] help with bivariate density plot question
Spencer Graves
spencer.graves at pdf.com
Sat Jul 12 17:17:48 CEST 2003
Did you look at "?contour"? The "contour" command has a "levels"
argument. To translate op into percentage, you could produce an
empirical CDF of op$zden.
hope this helps. spencer graves
liping wrote:
> Dear R users:
>
> I have a dataset with two variables (>20000 observations, two samples from same subject) and I used "kernSur" from library(Genkern) to
> get a estimated bivariate density and corresponding plots as follows:
>
> new.data.normal<-data.normal[!is.na(data.normal[,2]),]
> x<-new.data.normal[,2]
> y<-new.data.normal[,3]
>
> op <- KernSur(x,y, xgridsize=50, ygridsize=50, correlation=0.4968023,
> xbandwidth=1, ybandwidth=1)
>
> #3D density plot
> persp(op$xvals, op$yvals, op$zden,
> theta=30,phi=10,expand=0.5,ltheta=120,
> xlab="TECH3661.A",ylab="TECH3661.B",zlab="Prob",col="pink",
> , main="3D DENSITY PLOT-TECH3661 ", sub=" TECH3661.A AND TECH3661.B",
> box = T, axes = TRUE,ticktype = "detailed", )
>
> #countour plot
> image(op$xvals, op$yvals, op$zden, col=terrain.colors(100), axes=TRUE,xlab="TECH3661.A",ylab="TECH3661.B")
> points(x,y,pch="*")
>
> Now after above step, how can I use 'contour' or other commands to draw ellipse curves over above plots indicating "including about 68% data", "including about 84% data", etc. similar to the (-std,std), (-2*std,2*std),(-3*std, 3*std) intervals for univariate variable.
>
> any suggestin will be appreciated.
>
> liping
>
>
>
>
>
>
>
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://www.stat.math.ethz.ch/mailman/listinfo/r-help
More information about the R-help
mailing list