On 5/17/2007 3:42 PM, David Kaplan wrote: > Hi, this is simple, > > I've generated a bivariate normal distribution with a known correlation. > I want to plot the density function with p(y,x) on the vertical axis > and x, and y on the horizontal axes. How is that done? Thanks in advance! > > > library(MASS) > mu <- c(0,1) # mean vector > sigma <- matrix(c(1,.8,.8,1), ncol=2) > tmp <- mvrnorm(1000, mu, sigma) > cor(tmp) > plot(tmp,ylab='achievement', xlab='ses') # plot data
You need to calculate the density for each element of an array whose rows correspond to x values, and columns to y values. Then persp or contour can plot it (or persp3d in the rgl package). Duncan Murdoch ______________________________________________ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.