I am seeking an algorithm with two inputs and one output.
As the first input, consider any sorted finite sequence $s_1, s_2, ..., s_n$. The second input is a rank-order correlation parameter $\rho\in [-1, 1]$. The output of the algorithm is a new sequence of the same length as the original input sequence, call this $(\phi_k)_{k=1}^n$.
My question is the following:
How to generate (in R, preferably) a random sequence $\phi_1, \phi_2, ..., \phi_n$ which is a permutation of the input sequence, such that the two sequences $(s_k)_{k=1}^n$ and $(\phi_k)_{k=1}^n$ have an expected rank-order correlation $\rho$?
Example. Consider as input the simple sequence consisting of all whole numbers from 1 to 12:
1 2 3 4 5 6 7 8 9 10 11 12
Then with perfect correlation ($\rho = 1$), it obviously always returns the same sequence:
1 2 3 4 5 6 7 8 9 10 11 12
With a high but non-perfect ($0\ll\rho < 1$) correlation, it might return:
1 2 4 3 5 6 9 7 8 10 11 12
However, it would return a random sequence, not necessarily that one. Notice that 3 and 4 have changed places, and 7, 8, 9 became 9, 7, 8. As you can see, there is still clearly an increasing trend. Higher numbers are more concentrated in the end and lower numbers in the beginning. But the relation is non-perfect, it is no longer a perfectly sorted sequence.
When $\rho = 0$ the output should be a permutation of the input sequence where there is no expected rank-order relation between the sequences. In other words, that would just be an ordinary random permutation where all possible permutations have equal likelihood of occurring.
When $\rho = -1$ the output would be a complete reversal of the input sequence:
12 11 10 9 8 7 6 5 4 3 2 1
Hope my question makes sense, otherwise please ask for any clarifications. Thanks in advance for any help.