Skip to contents

Converts the marginal response rates of two binary endpoints and their correlation into the probabilities of the four joint response patterns.

Usage

cellprob_binary2(pi1, pi2, rho, tol = 1e-10)

Arguments

pi1

Response rate of endpoint 1, strictly between 0 and 1.

pi2

Response rate of endpoint 2, strictly between 0 and 1.

rho

Correlation between the two endpoints.

tol

Tolerance for the feasibility check.

Value

A named numeric vector of the probabilities of the cells "00", "01", "10" and "11" (first digit: endpoint 1; second digit: endpoint 2), summing to 1.

Details

For two Bernoulli variables with response rates \(\pi_1\) and \(\pi_2\), the Pearson correlation \(\rho\) determines $$p_{11} = \pi_1 \pi_2 + \rho \sqrt{\pi_1 (1 - \pi_1) \pi_2 (1 - \pi_2)},$$ and \(p_{10} = \pi_1 - p_{11}\), \(p_{01} = \pi_2 - p_{11}\), \(p_{00} = 1 - p_{10} - p_{01} - p_{11}\). All four probabilities are non-negative only if \(\max(0, \pi_1 + \pi_2 - 1) \le p_{11} \le \min(\pi_1, \pi_2)\), which bounds the feasible range of \(\rho\). An error is raised if rho is outside this range by more than tol.

Examples

cellprob_binary2(pi1 = 0.3, pi2 = 0.4, rho = 0.3)
#>        00        01        10        11 
#> 0.4873498 0.2126502 0.1126502 0.1873498