Let be x1$\mathbf x_1$ and y1$\mathbf y_1$, both of length n1$n_1$, a pair of vectors that represents the age and weight of n1$n_1$ male individuals, and x2$\mathbf x_2$ and y2$\mathbf y_2$, both of length n2$n_2$, a pair of vectors that represents the age and weight of n2$n_2$ female individuals. The number of males may be different than the number of females.
Let rho1$\rho_1$ be the Pearson's correlation coefficient between x1$\mathbf x_1$ and y1$\mathbf y_1$, and rho2$\rho_2$ the Pearson's correlation coefficient between x2$\mathbf x_2$ and y2$\mathbf y_2$. To reject the null hypothesis that rho1=rho2$\rho_1=\rho_2$ using a permutation test I should create random vectors where paired elements of x1/y1$\mathbf x_1/\mathbf y_1$ are swapped with paired elements of x2/y2$\mathbf x_2/\mathbf y_2$, in order to remove the relationship between the measurements and the labels (male/female).
The complete enumeration of all possible order of the data would be equal to all the possible order of the vector x (y)$\mathbf x (\mathbf y)$ built by concatenating the two vectors x1 x2 (y1 y2)$\mathbf x_1 \mathbf x_2 (\mathbf y_1 \mathbf y_2)$, that is (n1+n2)$(n_1+n_2)$! This makes my complete enumeration impossible, and I need to sample N$N$ configurations from all the possible configuration of x$\mathbf x$, of length n1+n2$n_1+n_2$.
Each possible configuration will swap a random number R$R$ of (paired) elements from x1/y1$\mathbf x_1/\mathbf y_1$ to x2/y2$\mathbf x_2/\mathbf y_2$, and I would like to know if R$R$ follows any known distribution.
Let then v$\mathbf v$ be a vector of length n1+n2$n_1+n_2$, built by concatenating a vector v1$\mathbf v_1$, that includes n1$n_1$ elements set to 0$0$ representing x1/y1$\mathbf x_1/\mathbf y_1$, and v2$\mathbf v_2$ that includes n2$n_2$ elements set to 1$1$ representing x2/y2$\mathbf x_2/\mathbf y_2$. Let then shuffle the element of v$\mathbf v$ for N$N$ times, and count, at each step i$i$ (with i in [i, N]$i \in [i, N]$), how many elements c_i$c_i$ of n1$n_1$ are now set to 1$1$, that is, how many elements were swapped at that permutation step. Let then build the distribution of my permuted elements c$c$.
I have run some simulations with different values of n1/n2$n_1/n_2$, and what I obtained (see plots below) are normal distributions, as also confirmed by the function fitdist fitdist
(in the R package fitdistrplusfitdistrplus
). Let me underline that the right tail is limited by the length of the shortest vector, that is, I can't permute more elements than those included in the shorter vector (see the plot on the bottom right for an example).
The problem (restated): How to estimate the parameters of the normal distributions (mu$\mu$ and sigma$\sigma$) showed above, by using only n1$n_1$ and n2$n_2$?
After running several simulation, varying n1/n2$n_1/n_2$, it seems to me that the mean mu$\mu$ is a function of the length of the smaller vector (let's say n1$n_1$) and the square root of the ratio between the two lengths, that is mu = n1 * (-0.604 * sqrt(n1/n2) + 1.101).:
$$\mu = n_1 \cdot \left(-0.604 \cdot \sqrt{\frac{n_1}{n_2}} + 1.101\right)$$
However, I can't find a way to calculate sigma $\sigma$ --and I am not sure that what I did to evaluate mu$\mu$ is very correct.
My question is: does anyone know how to evaluate, in a formal or empirical way, the parameters of the normal distributions (mu$\mu$ and sigma$\sigma$) build by counting how many elements are swapped (in average) between the two arrays in each data configuration?