# distribution function of the difference of two correlated chi-squared variables

I am trying to get the probability distribution function of the difference of two correlated chi-squared variable, $Z=X−Y.$ Given that $f_X(x)$ and $f_Y(y)$ are known, and both variables are chi-squaree distributed. $X$ and $Y$ have the same degree of freedom. lets assume that the mean and variance values for $X$ and $Y$ are $\mu_x, \sigma^2_x$ and $\mu_y$ and $\sigma_y^2,$ respectively. the covariance between $X$ and $Y$ is $\sigma_{xy}.$ So how can I calculate the variance and distribution of $Z$ ($f_Z(z)$). what if $\sigma_y^2= \sigma_x^2$?

• There are infinitely many models that allow for marginal $X$ and $Y$ Chi-squared random variables, so to find the distribution of their difference, given that they are dependent, you will need the joint pdf of $(X,Y)$, which you have not specified. By contrast, you can find Var(Z) immediately, given Var(X), Var(Y) and Cov(X,Y), via $$Var(Z) = Var(X) + Var(Y) - 2Cov(X,Y)$$ – wolfies Aug 25 '16 at 15:58
• I have tried to edit your Question, using standard notation. There were some ambiguities. Please check that I have not changed the meaning. – BruceET Aug 25 '16 at 16:25
• Thanks for the comments. But I have no idea about the joint PDF! – Ali Aug 25 '16 at 16:48
• As in my Answer, I think you need a model that explains the source of correlation. For example, in my (1) you could say $X = A+B$ and $Y = B+C,$ get the tri-variate distribution of $A, B, C,$ whence the bivariate distribution of $X,Y.$ You haven't told us the context of the problem, so there is no way for us to know how to model the covariance. To know the shape of the bivariate dist'n of X and Y, one needs more than the moments. In the background is there a lurking mechanism for the connection between X and Y? (In my Answ it's inherited from overlapping normals.) – BruceET Aug 25 '16 at 17:56
• The distribution of the difference depends on how they're dependent, not just the size of the correlation. The question needs more details. – Glen_b Aug 31 '16 at 3:04

Comment. Here are a couple of examples. I hope they will help clarify the Question, and perhaps help you find an answer.

(1) Suppose $Z_1, \dots, Z_5$ are iid standard normal. Then $X = Z_1^2 + Z_2^2 + Z_3^2$ and $Y = Z_3^2 + Z_4^2 + Z_5^2$ are both distributed $Chisq(df=3),$ but they are correlated because of they 'share' $Z_3^2.$ I will show some approximate quantities using simulation. You should be able to find some or all of the exact values by analysis.

m = 10^5;  n = 5;  z = rnorm(m*n)
DTA = matrix(z, nrow=m) # each row is std norm samp of 5
DTA2 = DTA^2
x = rowSums(DTA2[ ,1:3]); y = rowSums(DTA2[ ,3:5])
mean(x); mean(y)
## 3.003144  # aprx E(X) = 3
## 2.989661  # aprx E(Y) = 3
var(x); var(y); cov(x,y); cor(x,y)
## 6.013771  # aprx Var(X) = 6
## 5.936772  # aprx Var(Y) = 6
## 1.970101  # aprx Cov(x,Y)
## 0.3297159
mean(x-y); var(x-y)
## 0.01348286  # aprx E(X-Y)
## 8.010341    # aprx V(X-Y)


Below are histograms of the simulated distributions of $X$ and $Y$ along with the exact density of $Chisq(3).$ The third panel shows the simulated distribution of $X - Y$ along with its density estimator (roughly, a smoothed histogram). (2) Now suppose the $Z_i$ are as before, but $X = Z_1^2 + Z_2^2 + Z_3^2$ and $Y = Z_2^2 + Z_3^2 + Z_4^2,$ so the distributions of $X$ and $Y$ are as in (1), but their covariance is greater because of the increased 'overlap'. Notice the change in $Cov(X,Y)$ and in the distribution of $X - Y$

x = rowSums(DTA2[ ,1:3]); y = rowSums(DTA2[ ,2:4])
mean(x); mean(y)
## 3.003144
## 2.994843
var(x); var(y); cov(x,y); cor(x,y)
## 6.013771
## 5.997225
## 3.990319
## 0.6644449
mean(x-y); var(x-y)
## 0.008301117
## 4.030358 (3) At an absurd extreme,, $X \equiv Y \sim Chisq(\nu).$ Then $X - Y \equiv 0$ (degenerate), and $E(X-Y) = Var(X-Y) = 0$.

Finally, because you're trying to visualize joint distributions, here are plots of the simulated joint distributions in (1) and (2). In each case the joint distribution is suggested by showing 100,000 realizations of the model. All four marginals are $Chisq(3).$ 