import osif"KERAS_BACKEND"notin os.environ:# set this to "torch", "tensorflow", or "jax" os.environ["KERAS_BACKEND"] ="jax"import numpy as npimport bayesflow as bfimport matplotlib.pyplot as plt
INFO:bayesflow:Using backend 'jax'
In this example we will estimate a Pearson’s correlation coefficient, assuming known reliability of measurement of the two variables. We will assume that the true variable \(y\) and measurement error \(\epsilon\) are independent and so the measurement variance is simply a sum of the true and error variances, \(\sigma_x^2 = \sigma^2 + \sigma_\epsilon^2\), and reliability is then \(a=\frac{\sigma^2}{\sigma_x^2}\).
We will conduct an inference for the correlation coefficient for the data reported in Lee & Wagenmakers (2013, p. 64) of response times and IQ scores of 11 participants.
The original example by Lee & Wagenmakers sets the measurement error to 0.03 and 1 for RTs and IQ, respectivelly. Our model is parametrized in terms of measurement reliability instead. We approximate the reliabilities using the formula \(1 - \sigma_\epsilon^2 / \sigma_x^2\). Here, \(\sigma_\epsilon\) are the values \(0.03\) and \(1\) set by Lee & Wagenmakers (2013). In the case of RTs, we approximate \(\sigma_x\) by its sample counterpart. In the case of IQ, we set it’s \(\sigma_x=15\) (since that’s how IQ tests are standardized).