Three-way interactions with latent variables: a maximum likelihood approach