# Re: [R] Bivariate normal distribution and correlation

From: Spencer Graves <spencer.graves_at_pdf.com>
Date: Sat 19 Mar 2005 - 06:36:13 EST

Suppose you have the bivariate cumulative distribution function (cdf) for (X, Y).

1. From this first compute the marginal cdf for X. The median will give you EX, and you can get sigmaX = IQR/(2*qnorm(0.75)), where IQR = interquartile range = diff(quantile(..., c(0.25, 0.75))). Repeat to get EY and sigmaY.
2. Next compute the median of the conditional distribution for Y given X = (EX+sigmaX). This is E(Y|X=EX+sigmaX) = EY+rho*sigmaY. [The regression equation is E(Y|x) = EY + rho*(x-EX)*sigmaY/sigmaX, and (x-EX) = sigmaX by choice.] From this, you can now solve for rho. You may also wish to repeat this for EX-sigmaX as a check.

If you have trouble translating this into R code, please make an attempt, then read the posting guide
"http://www.R-project.org/posting-guide.html", and prepare a follow-up question as needed. (In a discussion on and off this list earlier this week, several people confirmed that they had solved many problems following this posting guide. It may not be as good as Polya's famous "How to Solve It", but it's pretty good.)

```      hope this helps.
spencer

```

Pekka Vimpari wrote:

>Suppose I know the value of cumulative bivariate standard normal distribution. How can I solve correlation between variables?
>
>
>
>Pekka
>
>
>
>---------------------------------
>
>
> [[alternative HTML version deleted]]
>
>______________________________________________
>R-help@stat.math.ethz.ch mailing list
>https://stat.ethz.ch/mailman/listinfo/r-help