Sample posterior distribution of correlation for bivariate uniform distribution

I want to fit some model in Stan. One of the important steps is to fit the correlation between 2 uniformly [0,1] distributed variables.

Dummy data generation:

N = 10 # number of trials
sigma = 0.1 # add some noise

y <- runif(N,min=(x-sigma),max=(x+sigma))
x <-(x-min(x))/(max(x)-min(x))
y <- (y-min(y))/(max(y)-min(y))

Can I use the standard approach, the same as for the normal distribution (lkj or lkj_corr_cholesky priors and so on) or are there better approaches for dealing with such an issue?

Does the dummy data generation that you provide actually implement the generative model that you want to fit? Or is it a quick-and-dirty way to generate some roughly bivariate-uniformish-but-correlated looking data? Note that in the data generation, neither x nor y is ultimately sampled from a uniform marginal distribution (for one thing, both x and y will always contain the elements 0 and 1).

Assuming that the dummy data generation above is not the generative model that you want to invert and fit, note that there are (many) multiple bivariate distributions whose margins are uniform and whose correlations take any particular value. So it will be important to figure out which (family of) bivariate uniform distribution you want to fit. If you’re able to go into a bit more detail about your system and how these numbers are produced, perhaps we can help you figure out how to write down an appropriate generative model.

1 Like

Thank you for your response. You’re right, I was trying to generate a bi-variate uniform distribution, with somehow correlated variables. My real data are “ranks” between 0 and 1. I can easily convert them to real ranks: if I have N observations, than X_rank = x_raw*(N-1)+1. I am interested in the correlation between the two variables.