Simulated example of a 3 way interaction GxExz model (where G and E are latent variables).
$$g_j \sim Binomial(n=1,p=.30)$$
$$j = 1, 2, 3, 4$$
$$e_l \sim Normal(\mu=0,\sigma=1.5)$$
$$l = 1, 2, 3$$
$$z \sim Normal(\mu=3,\sigma=1)$$
$$g = .2g_1 + .15g_2 - .3g_3 + .1g_4 + .05g_1g_3 + .2g_2g_3$$
$$e = -.45e_1 + .35e_2 + .2e_3$$
$$\mu = -2 + 2g + 3e + z + 5ge - 1.5ez + 2gz + 2gez$$
\(y \sim Normal(\mu=\mu,\sigma=\code{sigma})\) if logit =FALSE | \(y \sim Binomial(n=1,p=logit(\mu))\) if logit =TRUE |