P.S. just "pnorm(x, mean=m, sd=s)", not "1-pnorm(x, mean=m, sd=s) + pnorm(-x, mean=m, sd=s)"
On Wed, Oct 1, 2008 at 2:04 PM, Sasha Pustota <[EMAIL PROTECTED]> wrote: > Thanks Jay. I realized that I was doing it a silly way shortly after I > posted and that the answer i was looking for is simply > > condXY(y, x, my, mx, r) * dnorm(y, my) > > condXY <- function(y, x, my, mx, r) { > m <- mx + r*(y - my) > s <- sqrt(1-r^2) > p <- 1 - pnorm(x, mean=m, sd=s) + pnorm(-x, mean=m, sd=s) > } > > > On Wed, Oct 1, 2008 at 1:11 PM, G. Jay Kerns <[EMAIL PROTECTED]> wrote: >> Dear Sasha, >> >> On Wed, Oct 1, 2008 at 11:43 AM, Sasha Pustota <[EMAIL PROTECTED]> wrote: >>> Package mvtnorm provides dmvnorm, pmvnorm that can be used to compute >>> Pr(X=x,Y=y) and Pr(X<x,Y<y) for a bivariate normal. >>> >>> Are there functions that would compute Pr(X<x,Y=y)? >>> I'm currently using "integrate" with dmvnorm but it is too slow. >> >> >> Strictly speaking, the probability that you are asking to calculate is >> always 0, for every value of y. The reason is that the quantity you >> are requesting is the _volume_ of a vertical slice, at the value y, >> which is zero. It may be useful to think carefully about the problem >> you are trying to solve... perhaps a conditional probability is more >> appropriate. >> >> You did not say exactly which integral you are trying to compute: >> conceivably it would be >> >> \int_{-\infty}^{x} f(u, y) du, >> >> where f(.,.) is the bivariate normal pdf. If this is indeed what you >> want, then a work-around would be to calculate P( X < x | Y = y ). We >> know that given Y=y, X is normal with mean and variance formulas given >> in most introductory statistics books. Thus, you could compute P( X < >> x | Y = y ) with pnorm(x, mean = something, sd = something). >> >> In that case, the integral above would simply be P( X < x | Y=y ) * >> f(y), where f(y) is the marginal pdf of Y (a dnorm). >> >> Note that the above is assuming that y is a fixed constant; if not, >> then you may want to check out the Ryacas package. >> >> I hope that this helps, >> Jay >> >> >> >> >> >> *************************************************** >> G. Jay Kerns, Ph.D. >> Associate Professor >> Department of Mathematics & Statistics >> Youngstown State University >> Youngstown, OH 44555-0002 USA >> Office: 1035 Cushwa Hall >> Phone: (330) 941-3310 Office (voice mail) >> -3302 Department >> -3170 FAX >> E-mail: [EMAIL PROTECTED] >> http://www.cc.ysu.edu/~gjkerns/ >> > ______________________________________________ R-help@r-project.org 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.