# Bayesian method to compare correlations

I have read up on Bayesian methods enough now to feel that I would rather use Bayesian analysis over Frequentist, the trouble now is finding the correct tools...

I have data from an experiment with two groups of inbred fly lines and the measured variable is a continuous numeric value. Each group contains 40 genetic lines, within each line the response (longevity) of 200 males in 4 blocks (4*50) and 200 females in 4 blocks was measured.

I would like to compare the correlation in group A (gA) to the correlation in group B (gB) because gB is predicted to have a lower cross-sex genetic correlation than gA. The main aim is to show that the cross-sex genetic correlation for gB is significantly lower than gA - biologically speaking it still supports the theory if the correlation for gB was 0.8, just as long as it is less than the gA correlation. However, it is predicted from a similar previous study and theory that gB should have a correlation around 0, and gA a correlation of around 0.5.

What Bayesian analysis tools (ideally in R) can be used to assess this?

I'm thinking maybe I could measure the correlation in one and test the other using that correlation as a prior to see if it is significantly different from the prior.

Here is some dummy data but you should note I have not set a correlation between the males and females of the A group which is what is expected under the theory tested - it's quite complex to do this so it will take me some time and I'm waist deep in marking student reports. From this current data the correlations for both groups should be 0 (randomly generated numbers).

# lines groups sexes focals blocks
l = 40
g = 2
s = 2
f = 50
b = 4

dummy.df = data.frame(c(rep("M",l*g*f*b),(rep("F",l*g*f*b))))
colnames(dummy.df) = "gender"

dummy.df$line = rep(rep(1:l, each = f*b),each = s) dummy.df$group = rep( c(rep("A",f*b),rep("B",f*b)), each = 1)
dummy.df$block = rep(1:b, each = f) dummy.df$fly   = 1:(l*g*s*f*b)

# with random uncorrelated lifespans
# note: according to the hypothesis the sexes would correlate in group A (~0.5)
# such that lines with long life males also have long life females, and in the B group the sexes would be independent of each other
dummy.df$life = rnorm(length(dummy.df$group),50,5)