R-squared of a Latent Interaction in Structural Equation Model: A Tutorial of Using R

Mplus (Muthén & Muthén, 1998 2017) is one popular statistical software to estimate the latent interaction effects using the latent moderated structural equation approach (LMS). However, the variance explained by a latent interaction that supports the interpretation of estimation results is not currently available from the Mplus output. To relieve human computations and to facilitate interpretations of latent interaction effects in social science research, we developed two functions (LIR & LOIR) in the R package IRmplus to calculate the R-squared of a latent interaction above and beyond the first-order simple main effects in Structural Equation Modeling. This tutorial provides a step-by-step guide for applied researchers to estimating a latent interaction effect in Mplus, and to obtaining the R-squared of a latent interaction effect using the LIR & LOIR functions. Example data and syntax are available online.


A Brief Overview of the -squared of Latent Interaction
Interactions between two latent variables are often estimated in structural equation models (SEM). SEM allows for testing a variety of hypothesized models to explain the relationships among a set of latent factors and observed variables (e.g., Bollen, 1989;Ullman & Bentler, 2003). SEM is composed of a measurement model and a structural model (Schumacker & Lomax, 2004). The measurement model examines the associations between latent factors and observed indicators. Let be an ℎ individual, be a number of observed indicators, and be a number of latent factors. The measurement model is expressed in Equation (1) as: where i is a × 1 vector of observed indicators, is a × 1vector of intercepts, is a × matrix of factor loadings, i is a × 1 vector of latent factors, and i is a × 1 vector of measurement errors that assumes a multivariate normal distribution with a mean vector of and a diagonal matrix of .
The structural model explains the relationships among latent factors or among latent factors and observed covariates. The two-way latent interactions can be estimated in the structural model under two scenarios: (1) between latent factors, and (2) between a latent factor and an observed covariate, detailed in the following scenarios.

Scenario 1: Structural Model with a Two-way Interaction between Latent Factors
Consider a model with one endogenous variable and two exogenous variables ( 1 , 2 ), denoted as i = ( , 1 , 2 ). A two-way latent interaction term between two exogenous variables, 1 2 , is also included, as depicted in Figure 1. Note. Structural equation model with one latent interaction effect between two latent factors. Each of , 1 , and 2 has five observed indicators (e.g., 1 , … , 5 ; 6 , … , 10 ; 11 , … , 15 ) as a measurement model. Note that the latent interaction term 1 2 is produced with LMS approach here.
The structural part of this model is expressed in Equation (2) as: = + 1 1 + 2 2 + 1 2 1 2 + , where is the intercept of the endogenous latent factor , 1 is the regression coefficient assessing the effect of the exogenous latent factor 1 on the endogenous latent factor , 2 is the regression coefficient assessing the effect of the latent moderator 2 on the endogenous latent factor , 1 2 is the regression coefficient measuring the latent interaction effect 1 2 (typically estimated by the LMS approach) on the endogenous latent factor , Klein and Moosbrugger (2000) proposed the LMS approach to directly claim latent interaction in the structural equation in SEM. More detailed technical introduction of the LMS approach can be found in the Klein and Moosbrugger (2000), Klein and Muthé n (2007), Kelava et al. (2011), andPreacher, Zhang, andZyphur (2016). Given that the latent interaction is assumed to have no covariance with the first-order simple main effects (Klein & Moorusberg, 2011), the -squared of a latent interaction can be calculated in the following two steps (Maslowsky, Jager, & Hemken, 2015).
The first step is to compute the -squared of the simple main effects 0 2 without the latent interaction as follows: where 1 2 is the variance of the exogenous latent factor 1 , 2 2 is the variance of the latent moderator 2 , 2 is the disturbance variance of the endogenous latent factor .
The second step is to compute the -squared of where 1 2 2 is the covariance between the exogenous latent factor 1 and the latent moderator 2 .
Lastly, the -squared of the latent interaction is computed as: 1 2 − 0 2 , which indicates the additional proportion of variances explained by a two-way interaction above and beyond the simple main effects.

Scenario 2: Structural Model with a Two-way Interaction between a Latent Factor and an Observed Covariate
Consider a model with an endogenous latent factor , an exogenous latent factor , an observed covariate , and a latent interaction term produced by the LMS approach, as depicted in Figure 2.

Figure 2. Diagram of a Structural Equation Model: Two-way Interaction between a Latent Factor and an Observed Indicator
Note. Structural equation model with one latent interaction effect between an exogenous latent factor and an observed covariate. Each of and has five observed indicators (e.g., 1 , … , 5 ; 6 , … , 10 ) as a measurement model. Note that the latent interaction term is produced with LMS approach here.
In this case, the latent factor vector is: i = ( , ). The structural model including the two-way interaction between a latent factor and an observed covariate can be expressed as: where is the regression coefficient assessing the effect of the exogenous latent factor on the endogenous latent factor , is the regression coefficient assessing the effect of the observed covariate on the endogenous latent factor , is the regression coefficient measuring the latent interaction effect on the endogenous latent factor .

The IRmplus Package
Two-way latent interactions are common in social science research and the modeling of latent interactions has brought increasing attention. The LIR and LOIR functions in the IRmplus package were developed to compute the -squared of a single two-way latent interaction in the SEM given the Mplus output, following Equations (1) through (7). The LMS approach, implemented using the XWITH command in Mplus, is one popular method to estimate the two-way interactions, whereas the Mplus output lacks the effect size estimates unless fitting to a dataset with all variables standardized. To employ IRmplus, Two Mplus outputs are necessary: one for the model without the latent interaction, and one for the model including the latent interaction. IRmplus reads needed parameter estimates from the Mplus outputs and uses them as the input to compute latent interaction effects. Table 1 presents two functions, LIR and LOIR, included in the IRmplus package, that compute the -squared of a latent interaction for the two scenarios discussed above.

LMS
Compute 2 of an interaction effect between a latent factor and an observed variable in SEM model in Mplus The LIR and LOIR functions were developed to compute the -squared of a latent interaction one at a time. If multiple two-way interactions exist in the structural model, the LIR and/or LOIR functions can be executed multiple times to obtain the unique proportion of variances explained by the individual latent interaction.
The LIR and LOIR functions include six main arguments. The "M0" reads the Mplus output containing only simple main effects. The "M1" reads the Mplus output containing both simple main effects and latent interaction effects. The "endogenous" is the endogenous latent factor shown on the Mplus output. The "exogenous" is the exogenous latent factor shown on the Mplus output. The "moderator" is the moderator variable shown on the Mplus output, which can be a latent factor or an observed covariate in the structural model. The "interaction" is the interaction term produced by the XWITH function and shown on the Mplus output. The two examples below present the Mplus and R scripts for computing the latent interaction 2 using the IRmplus package.

Two-way Interaction between Latent Factors
To demonstrate the utility of functions in the IRmplus package, we simulated two data sets to provide step-by-step guide to computing the two-way interaction between latent factors in a SEM model 1 . The first dataset is read as "Example1.dat". The data generation model contains three latent factors and 15 observed indicators ( 1 , … , 15 ), where 1 to 5 measure the exogenous latent factor F1, 6 to 10 measure the latent moderator F2, and 11 to 15 measure the endogenous latent factor F3. In the structural model, F3 is regressed on F1, F2, and the interaction term between F1 and F2. We use F in this section to label latent variables because this is a common label Mplus reads for the latent variables. The F1, F2, and F3 here correspond to the 1 , 2 , and in Equations (2) through (4).
Because IRmplus is published on GitHub, the devtools package is required before installing and loading the IRmplus package from GitHub 2 . The IRmplus package is built upon the MplusAutomation, stringr, tidyverse, and stringi packages and it only needs to be installed once. However, loading the packages (library()) is needed every time when the R program starts.
install.packages("devtools") library(devtools) install_github("luluqinqin/IRmplus") library(IRmplus) Next, we need to prepare the Mplus syntax following a two-step procedure. First, a three-factor SEM model without interactions is fitted, where the endogenous latent factor F3 is regressed on the exogenous latent factors F1 and F2. The syntax is presented below and needs to be saved as an external Mplus input file (e.g., "SEM_NoINT.inp"). Second, we prepare the syntax for the three-factor SEM model with a two-way latent interaction to estimate the interaction effect between exogenous latent factors F1 and F2. The syntax is shown below and saved as another external Mplus input file (e.g., "SEM_INT.inp"). OUTPUT: SAMPSTAT; After running the two Mplus input files, we obtain two Mplus output files (e.g., "sem_noint.out", "sem_int.out"), which will serve as the inputs for running the LIR function. Because the interaction is between two latent factors, the LIR function from the IRmplus is used to calculate the -squared of the latent interaction between F1 and F2 following the command below.
LIR (M0 = "sem_noint.out", M1 = "sem_int.out", endogenous = "F3", exogenous = "F1", moderator = "F2", interaction = "INTER") > 0.127 In the LIR function arguments, the exogenous latent factor is "F1", the moderator is "F2", the endogenous latent factor is "F3", and the interaction term "INTER" is produced by XWITH function in Mplus syntax. It is to note that the R script is case-sensitive so that the IRmplus arguments (e.g., "INTER") need to be the same as that shown on the Mplus output. In this example, the LIR function returns the -squared of a latent interaction as 0.127, which indicates that the two-way latent interaction explains around 13% additional variances above and beyond the simple main effects of exogenous latent factors.

Two-way Interaction between a Latent Variable and an Observed Covariate
To use the LOIR function in the IRmplus package for the computation of the -squared of the latent interaction between a latent factor and an observed covariate using the second simulated dataset "Example2.dat". The data generation model contains 15 observed indicators measuring three latent factors (the same measurement model as that in example 1) and one binary covariate (Gender). In the structural model, F3 is regressed on F1, F2, Gender, and the interaction term between F1 and Gender. The F1, F3, and Gender here correspond to the , , and Z in Equations (5) through (7).
We only present the MODEL command in the Mplus syntax below, as other commands are similar to those in the first example. The same two-step procedure is followed. First, the model with only the main effects is fitted and the syntax is saved (e.g., "SEM2_NoINT.inp). The WITH function in the Mplus syntax above is used to request the covariance estimate between an exogenous latent factor and an observed covariate. Although "F1 WITH gender" and "gender WITH F1" both provide the same covariance estimate, the LOIR function only supports the syntax starting with the exogenous latent factor, which is "F1 WITH gender" in this example.

MODEL
In the LOIR function arguments, the exogenous latent factor is "F1", the moderator is "GENDER", the endogenous latent factor is "F3", and the interaction term is "INTER2". To match the variable names printed on the Mplus output, the moderator and interaction term are both capitalized in the LOIR function. The -squared estimation is computed as 0.102, indicating 10% of the variances are attributable to the latent interaction term.

Discussion
The attractive features of the LIR and LOIR functions in the IRmplus package include that it minimizes errors due to human misjudges (e.g., output misinterpretation/hand calculation), and promotes the applications and interpretations of latent interactions in latent variable modeling. However, the IRmplus package is limited in some ways that would serve as our future research directions. It requires multiple executions of the LIR and/or LOIR functions when multiple two-way interactions are presented in complex modeling. Future developments of the IRmplus package include exploring the calculation of the effect size for the 3-way latent interaction, estimation of interaction effects using other estimation approaches (e.g., product indicator approach), and automatic computation of multiple latent interaction terms.

Conclusions
The IRmplus package connects two popular statistical programs, Mplus and R, to provide an effective computation of latent interactions between two latent variables, or between a latent variable and an observed indicator. The current version of IRmplus (v1.0) supports outputs from Mplus version 8. We will continue incorporating more advanced latent variable models and developing new functions to support newly methodological developments. We hope that the package will be a practical tool to assist researchers to better understand the impact of latent interactions. The authors are grateful for any feedback and suggestions.