I need to generate a series of N random binary variables with a given correlation function. Let x = {xi} be a series of binary variables (taking the value 0 or 1, i running from 1 to N). The marginal probability is given Pr(xi = 1) = p, and the variables should be correlated in the following way:
Corr[ xi xj ] = const × |i−j|−α (for i!=j)
where α is a positive number.
If it is easier, consider the correlation function:
Corr[ xi xj ] = (|i−j|+1)−α
The essential part is that I want to investigate the behavior when the correlation function goes like a power law. (not α|i−j| )
Is it possible to generate a series like this, preferably in Python?
Thanks for all your inputs. I found an answer to my question in the cute little article by Chul Gyu Park et al., so in case anyone run into the same problem, look up:
“A simple method for Generating Correlated Binary Variates” (jstor.org.stable/2684925)
for a simple algorithm. The algorithm works if all the elements in the correlation matrix are positive, and for a general marginal distribution Pr(x_i)=p_i.
j