I have two discrete distributions and I wish to introduce dependence between them using a copula.
I can write the copula myself, but the output is P(X<=x, Y<=y). I wish to back out P(X=x, Y=y) = P(X<=x, Y<=y)- P(X<=x-1, Y<=y) - P(X<=x, Y<=y-1) + P(X<=x-1, Y<=y-1).
Previously I have done these using labelled structs in an e.g. vector. I could use a spare matrix of size M(max(x), max(y)) but I think it is inefficient in memory.
Is there a better way in Stan?