Motivated by the goal of expanding currently existing Genotype × Environment interaction (G × E) models to simultaneously include multiple genetic variants and environmental exposures in a parsimonious way, we developed a novel method to estimate the parameters in a G × E model, where G is a weighted sum of genetic variants (genetic score) and E is a weighted sum of environments (environmental score). The approach uses alternating optimization, an iterative process where the genetic score weights, the environmental score weights, and the main model parameters are estimated in turn, assuming the other parameters are constant. This technique can be used to construct relatively complex interaction models that are constrained to a particular structure, and hence contain fewer parameters. We present the model as a 2-way interaction longitudinal mixed model, for which ordinary linear regression is a special case, but it can easily be extended to be compatible with k-way interaction models and generalized linear mixed models. The model is implemented in R (LEGIT package) and using SAS macros (LEGIT_SAS). Through simulations, we demonstrate the power and validity of this approach even with small sample sizes. Furthermore, we present examples from the Maternal Adversity, Vulnerability, and Neurodevelopment (MAVAN) study where we improve significantly upon already existing models using alternating optimization.