# Chisquared distribution test in R

I'm reading the paper by Lourme A. et al (2016) and try to plot the Fig.2 from this paper. The question regarding to programming of confidence areas and my example in R is here.

4.1.2. Confidence areas

Let $u = (u_1,…,u_d)^\top$ be a random vector with uniform margins on $(0, 1)$ and let $y = (y_1,…, y_d)^\top \in \mathbb{R}^d$ be defined by: $y_j = G(u_j)$, $j \in \{1,…,d\}$ where $G$ is a continuous increasing map defined between 0 and 1.

Let us assume that the multivariate c.d.f of $u$ is a Gaussian copula with parameter $R_g$. Taking the quantile function of $N_1(0, 1)$ as $G$, then $y$ is distributed as $N_d(0, R_g)$ and the random variable $y^\top R_g^{-1} y$ as $\chi^2_d$. Given $\alpha \in (0, 1)$, the latter variable $y^\top R_g^{-1} y$ is less than $\chi^2_{d,\alpha}$ – the $\alpha$ order quantile of $\chi^2_d$ – with probability $\alpha$. Hence, $$\Gamma_g(\alpha) = \{ v= (v_1 ,…,v_d )^\top \in [0, 1]^d :\\ (G(v_1),…, G(v_d)) R_g^{-1}(G(v_1),…, G(v_d))^\top \leq\chi^2_{d,\alpha}\}$$ is a $d$-dimensional compact confidence area inside (resp. outside) of which $u$ falls with probability $\alpha$ (resp. $1-\alpha$).

$R_g$ is a $d × d$ correlation matrix.

Question. I have statistical questions about distribution.

How to statiscally check whether variable $y^\top R_g^{-1} y$ is distributed as $\chi^2_d$?

It's known that mean $M(\chi^2_d)=d$, and variance $D(\chi^2_d)=2d$, where d is degreee of freedom.

Edit. Is it possible to use the Kolmogorov-Smirnov test here?