Interaction Plots and Simple Slopes

This page reads an Mplus output file, draws the interaction between a predictor and a moderator, tests the simple slope of Y on X at chosen values of the moderator, and locates the Johnson–Neyman thresholds that fall inside the range of the moderator the data cover.

What to request from Mplus. OUTPUT: SAMPSTAT STDYX TECH1 TECH3 TECH4;. TECH1 numbers the free parameters and TECH3 prints their covariance matrix: together they give the standard error of a simple slope and the Johnson–Neyman thresholds. SAMPSTAT gives the means, standard deviations and observed minimum and maximum of the observed variables, used for the levels of the moderator and for the axes. TECH4 gives the estimated means, variances and covariances of the latent variables, which is where the page reads them when the interaction is between factors declared with XWITH. STDYX gives the standardized solution. Mplus prints all of them for a model with a latent interaction from Version 7.4 on (Muthén & Muthén, 2015); an earlier version writes a warning naming the option it refused, and the page then falls back on the Variances and WITH blocks of MODEL RESULTS and says so. A warning printed by Mplus is reported and does not remove a result the file supports; what removes a result is a quantity that is missing or inadmissible.

What to do

  1. Open the Mplus input file of the model that contains the interaction, the file with the extension .inp, and add this line to it, exactly as it is written here: OUTPUT: SAMPSTAT STDYX TECH1 TECH3 TECH4;
  2. Leave the line as it is when the interaction is between two latent variables declared with XWITH. That model is estimated with TYPE = RANDOM, and TECH4 is what carries the quantities the standardized solution needs: the estimated variances of the two factors, their covariance, and the estimated variance of the dependent variable when that is itself a factor. The product term does not appear among the rows of TECH4; its variance follows from the variances and the covariance of its two components. If the run answers with the warning that TECH4 or STANDARDIZED is not available for TYPE = RANDOM, which versions before 7.4 do (Muthén & Muthén, 2015), the page reads the variances of the factors from the Variances block and their covariance from the WITH block of MODEL RESULTS, takes their means as zero, which is where Mplus fixes them, and rebuilds the variance of the dependent variable from the model.
  3. Run that input in Mplus. The program writes a plain text file with the same name as the input and the extension .out, in the folder the input is in.
  4. Drag the .out file onto the box below, or press Choose the .out file and pick it there. The file is read inside your browser and semstudio.tools does not transmit the file contents; processing occurs in the browser.
  5. Read the paragraph headed Output read. It names every regression found in MODEL RESULTS, the estimator, whether TECH1 and TECH3 are in the file, and any row the program printed as asterisks.
  6. Choose the dependent variable, the predictor whose slope is drawn, and how the moderator enters the model: one continuous variable, one categorical variable with numeric codes, or a set of dummy variables with one product term each.
  7. Choose the moderator and the term that carries the product of the predictor and the moderator. The page names the coefficients it read for them; those values cannot be changed here.
  8. Set the levels of a continuous moderator at which the slope is to be drawn. They start at one standard deviation below the mean, at the mean and at one standard deviation above it, all three read from the file, and you can change them because which levels to draw is a decision about the figure. The codes of a categorical moderator are read from the file and cannot be changed or added to.
  9. Read the figure, the table of simple slopes under it, and the Johnson–Neyman section, which reports the values of the moderator at which the slope of Y on X stops differing from zero.
  10. Set the labels, the axes, the printed width and the resolution, then download the figure as SVG or as PNG.

The page does not process empty or truncated files, nonconverged runs, or output formats currently unsupported by the parser: TYPE = TWOLEVEL, mixture models, multiple groups, and ESTIMATOR = BAYES. A categorical moderator also requires its observed codes in the file. Inferential tests are reported only when the sampling covariance of the relevant coefficients can be recovered and checked against the printed standard errors. Coefficients, standard errors, means, and standard deviations are read from the output rather than entered manually.

Load the Mplus output

Mplus output file Drag the .out file anywhere on this page, or choose it with the button above. Windows-1252, UTF-8 and UTF-16 files are all decoded.

Methods and formulas

The simple slope and its standard error

The model behind every figure on this page is the linear regression of Y on a predictor X, a moderator W and their product, written as in chapter 2 of Aiken and West (1991) with W in place of their Z:

Y=b0+b1X+b2W+b3XW+e

Here Y is the dependent variable, b0 its intercept, X the predictor and b1 its coefficient, W the moderator and b2 its coefficient, b3 the coefficient of the product of X and W, and e the residual.

Collecting the terms in X gives the conditional regression of Y on X at a fixed value w of the moderator, whose slope, the simple slope, is a linear function of w:

Y=(b0+b2w)+(b1+b3w)X+e,s⁡(w)=b1+b3w

Here w is the value at which the moderator is held, b0 + b2w is the conditional intercept, and s(w) is the simple slope of Y on X at that value.

Because s⁡(w) is linear in the estimates, its sampling variance follows from the covariance matrix of the estimates without any approximation beyond the one already made in treating that matrix as the asymptotic covariance matrix. This is the delta method applied to a linear function (Aiken & West, 1991, ch. 2; Cohen, Cohen, West, & Aiken, 2003, p. 273; Bauer & Curran, 2005, eq. 13):

Var⁡[s⁡(w)]=Var⁡(b1)+w2Var⁡(b3)+2wCov⁡(b1,b3)

Here Var[s(w)] is the sampling variance of the simple slope at w, Var(b1) and Var(b3) are the sampling variances of the two coefficients, and Cov(b1, b3) is their sampling covariance, all three read from TECH3.

z=s⁡(w)Var⁡[s⁡(w)]

Here z is the test statistic of the simple slope at w, referred to the standard normal distribution.

The test uses the standard normal distribution, as Mplus does, and is therefore asymptotic. Small-sample results may differ from a finite-sample t procedure. For a categorical moderator represented by dummy variables, the slope in category j is b1 + gj, and its variance is obtained from the same parameter-covariance matrix:

Var⁡(b1+gj)=Var⁡(b1)+Var⁡(gj)+2Cov⁡(b1,gj)

Here gj is the coefficient of the product of X with the dummy variable of category j, Var(gj) its sampling variance, and Cov(b1, gj) its sampling covariance with b1.

The difference between the slopes of two non-reference categories i and j is gj−gi, with variance

Var⁡(gj−gi)=Var⁡(gi)+Var⁡(gj)−2Cov⁡(gi,gj)

Here gi and gj are the coefficients of the two product terms, and Cov(gi, gj) is their sampling covariance. The difference between category j and the reference category is gj itself.

The Johnson–Neyman quadratic

Johnson and Neyman (1936) asked for which values of a continuous variable two groups differ, which in the present notation is the question for which values of the moderator the conditional effect is distinguishable from zero. Setting the square of the test statistic equal to the square of the critical value z.975=1.96 and clearing the denominator turns that question into a quadratic equation in w (Bauer & Curran, 2005, eqs. 17–21; Preacher, Curran, & Bauer, 2006):

[s⁡(w)]2=z2Var⁡[s⁡(w)],that isaw2+bw+c=0

Here s(w) is the simple slope at w, z is the critical value 1.96, and a, b and c are the three coefficients of the quadratic given next.

a=b32−z2Var⁡(b3),b=2[b1b3−z2Cov⁡(b1,b3)],c=b12−z2Var⁡(b1)

Here b1 and b3 are the coefficients of X and of the product, Var(b1), Var(b3) and Cov(b1, b3) their sampling variances and covariance, and z the critical value 1.96.

Bauer and Curran (2005, eqs. 18–20) write the three coefficients with the opposite sign, a=tcrit2Var⁡(b3)−b32 and so on, and with the critical value of a t distribution; multiplying an equation by −1 leaves its roots unchanged, so the thresholds are the same, and with z = 1.96 in place of tcrit the two agree except in small samples. The sign rule below refers to the coefficients as written here. The quantity q⁡(w)=aw2+bw+c is positive exactly where the simple slope differs from zero at the 5% level. When a is positive the slope is significant outside the two roots, so there are two regions of significance, one below the smaller root and one above the larger; when a is negative there is one region, between the roots. Bauer and Curran (2005, p. 379) speak of “regions of significance” for the same reason. This page also evaluates q at the midpoint of each interval and reports a warning if the two ways of deciding disagree. Only roots that fall inside the range of the moderator the data actually cover are reported and drawn, because a threshold outside that range describes no observable case. For an observed moderator that range is read from the univariate sample statistics when the output contains them, and is otherwise taken as the mean plus or minus three standard deviations, both read from the file; a latent moderator has no observed range, so the second rule is used; the page states which of the two was used. The procedure does not apply to a categorical moderator, whose intermediate values do not exist.

The standardized solution for a product term

For observed product terms created in DEFINE, STDYX uses the standard deviation of the product variable itself. For latent interactions declared with XWITH, standardization instead uses the standard deviations of the two component variables (Asparouhov & Muthén, 2019, Eqs. 16–18). This matches the product-of-standardized-components formulation discussed by Wen, Marsh and Hau (2010). The product variance is therefore not used in the latent-interaction coefficient rescaling:

b1′=b1σXσY,b2′=b2σWσY,b3′=b3σXσWσY

Here b1′, b2′ and b3′ are the standardized coefficients of X, of W and of the product, b1, b2 and b3 the unstandardized ones, and σX, σW and σY the standard deviations of X, of W and of Y.

Under this rescaling the standardized simple slope of Y on X at a value w of the moderator is b1′+b3′w/σW, so the standardized coefficients and the standardized simple slopes describe the same equation, and all three are unchanged when X, W or Y is measured in different units: this is the scale-free property in the title of Wen, Marsh and Hau (2010). The value of b1′ is the standardized simple slope at W=0 in the original metric of W. It is the coefficient of standardized X in the regression of standardized Y on standardized X, standardized W and their product only when the mean of W is zero; otherwise that coefficient is (b1 + b3μW)σX/σY (Aiken & West, 1991, ch. 3), which is why the moderator is usually centered first. With latent variables, whose means Mplus fixes at zero, the two coincide. The table of the standardized solution has one column with the STDYX values of Mplus and one with the values rebuilt from the formulas above. For X and for W the two agree. For the product they agree as well when it is declared with XWITH, since both then divide by SD(X) SD(W), and differ by construction when the product is an observed variable, since Mplus then divides by its standard deviation; the page states which of the two cases the output is in and prints the difference.

For latent interactions declared with XWITH, the required standard deviations belong to latent variables. The page reads them from TECH4 when available. If TECH4 is absent, it uses the variance information printed for latent-interaction models where that reconstruction is supported and states which route was used. The product term itself need not appear in TECH4 because its moments follow from those of its components.

When the file has no TECH4 block, the variances of the factors are read from the Variances block and their covariance from the WITH block of MODEL RESULTS, their means are zero, and the total variance of Y is reconstructed from the model under joint normality of X and W, using the variance of a product of two normal variables given by Bohrnstedt and Goldberger (1969):

Var⁡(XW)=σX2σW2+σXW2+μX2σW2+μW2σX2+2μXμWσXW

Here Var(XW) is the variance of the product, σ2X and σ2W are the variances of X and W, σXW is their covariance, and μX and μW are their means.

Cov⁡(X,XW)=μWσX2+μXσXW,Cov⁡(W,XW)=μXσW2+μWσXW

The symbols are those of the previous formula: the covariance of each component with the product is built from the mean of the other component, the variance of the component itself and the covariance between the two.

σY2=b12σX2+b22σW2+b32Var⁡(XW)+2b1b2σXW+2b1b3Cov⁡(X,XW)+2b2b3Cov⁡(W,XW)+σe2

Here σ2Y is the total variance of Y implied by the model, b1, b2 and b3 are the three coefficients, the variances and covariances are those defined above, and σ2e is the residual variance of Y.

This is the same distributional assumption on which the latent moderated structural equations approach of Klein and Moosbrugger (2000) rests, and the reconstruction is reported as a reconstruction whenever it is used. With latent means fixed at zero the expression reduces to Var⁡(XW)=σX2σW2+σXW2, which is the form Asparouhov and Muthén (2019, eqs. 16–17) give for a latent product.

The two routes to the total variance of Y are reported together whenever the file supports both. Under the standardized solution the page names the one it used, prints what the other one gives, and prints the difference between them. That difference is compared with the effect of the rounding of the printed values: every quantity the reconstruction reads is printed to three decimals, so each carries an error of up to 0.0005, and the sum of the absolute first derivatives of the expression above with respect to the nine of them, each multiplied by 0.0005, bounds how far the reconstruction can fall from the value Mplus computed from its own unrounded estimates. A difference within that bound is rounding; a larger one means the equation read for Y is not the equation the estimated variance belongs to, and the page says so.

Predicted values and confidence bands

Each line in the figure is the predicted value of Y as a function of X at one value of the moderator. When the model contains predictors other than X, W and their product, they are held at their sample means as read from the file, and the product of each coefficient with its mean is added to the intercept; when a mean is not in the output the page says so and holds that predictor at zero. The confidence band around a line is the 95% interval for the conditional mean, computed from the same parameter covariance matrix as a quadratic form:

Var⁡(Y^|x,w)=r′Vr

Here Ŷ is the predicted mean at the values x of the predictor and w of the moderator, r is the row of the design matrix at that point, which holds a one for the intercept, x, w, their product and the mean of every other predictor, and V is the covariance matrix of the estimates from TECH3.

Y^±1.96Var⁡(Y^|x,w)

Here the two limits are the ends of the 95% interval for the conditional mean at that point, and 1.96 is the .975 quantile of the standard normal distribution.

The band requires the intercept, X, W and the product to be located in TECH1, and every other predictor of Y as well; when one of them cannot be located the band is omitted and the reason is stated under the figure.

What TECH1 and TECH3 contain

TECH1 prints the parameter specification: each free parameter of the model receives a number, and the numbers are laid out in the matrices of the general model, so that the coefficient of X in the regression of Y appears as an entry of Β or Γ in row Y and column X, and the intercept of Y appears in α or ν. Mplus prints these matrices in blocks of five columns, repeating the name of the matrix above each block, so a parser that stops at the first block loses every column from the sixth onwards; this page reads every block and keeps the column headings of each. TECH3 prints the covariance matrix of the parameter estimates, indexed by the same numbers. Reading the two together gives the exact sampling variances and covariance that the delta method needs. When TECH3 is absent, two other sources are tried in turn, and the table of simple slopes names the one used. The first applies only to a regression among observed variables fitted by maximum likelihood: the covariance matrix of the regression coefficients is then

V=σe2nS−1

Here V is the covariance matrix of the coefficients of the predictors of Y, σ2e is the residual variance of Y from MODEL RESULTS, n is the number of observations, and S is the sample covariance matrix of the predictors from SAMPSTAT, which Mplus computes with the divisor n.

The covariance reconstruction is limited to complete-data, unweighted observed-variable regressions estimated by ordinary maximum likelihood. It is not used with missing-data patterns, weights, bootstrap standard errors, TYPE = COMPLEX, TYPE = RANDOM, or latent predictors. Reconstructed standard errors must agree with the printed values within output-rounding tolerance. When TECH3 is available it is preferred; otherwise three simple slopes defined as NEW parameters can identify Var(b1), Var(b3) and Cov(b1, b3) if their names identify them as simple slopes.

Reading the output file

Files are decoded from the byte-order mark when present; otherwise UTF-8 is tested before falling back to Windows-1252. Fortran D exponents are converted, asterisks are treated as unread values, and 999.000 in all four columns is treated as an unavailable Mplus result. Unsupported model types, truncated files, unrecognized files, empty files, and nonconverged runs are reported without producing a plot. The estimator is read from SUMMARY OF ANALYSIS and only falls back to the echoed input when necessary; the fallback is disclosed.

Every quantity the page computes with is read from that file: the coefficients and their intercept from MODEL RESULTS; the means and variances of observed variables from the Means and Covariances blocks of SAMPLE STATISTICS, or from the mean and variance columns of UNIVARIATE SAMPLE STATISTICS when that block is the only one printed, and their observed minimum and maximum from the latter; the means, variances and covariances of latent variables from TECH4 when it is present and otherwise from the Variances and WITH blocks of MODEL RESULTS, with the mean of an exogenous factor taken as the zero Mplus fixes it at; the intercept of the equation from the Intercepts block, except for a latent dependent variable that gets no such line, whose intercept Mplus has fixed at zero and which the page states as fixed; the codes of a categorical moderator from the same statistics; and the sampling variances and covariances from TECH1 with TECH3. None of them can be typed in, and none of them can be edited after being read. What remains adjustable is the description of the figure: which levels of a continuous moderator to draw, the labels, the axes, the type size, the printed width and the resolution of the export.

Self-test

Append ?selftest=1 to run the in-browser checks. They cover normal-tail probabilities, simple slopes and delta-method variances, Johnson–Neyman roots and edge cases, standardized product terms, predicted-mean variance, categorical moderators, supported and unsupported output structures, TECH1/TECH3/TECH4 parsing, moderator coding, and latent-interaction variance reconstruction. Randomized checks compare analytical results with independent algebraic or Monte Carlo calculations.

References

  • Aiken, L. S., & West, S. G. (1991). Multiple regression: Testing and interpreting interactions. Sage.
  • Asparouhov, T., & Muthén, B. (2019). Latent variable interactions using maximum-likelihood and Bayesian estimation for single- and two-level models (Mplus Web Note No. 23). Muthén & Muthén. (No digital object identifier.) https://www.statmodel.com/examples/webnotes/webnote23.pdf
  • Bauer, D. J., & Curran, P. J. (2005). Probing interactions in fixed and multilevel regression: Inferential and graphical techniques. Multivariate Behavioral Research, 40(3), 373–400. https://doi.org/10.1207/s15327906mbr4003_5
  • Bohrnstedt, G. W., & Goldberger, A. S. (1969). On the exact covariance of products of random variables. Journal of the American Statistical Association, 64(328), 1439–1442. https://doi.org/10.1080/01621459.1969.10501069
  • Cohen, J., Cohen, P., West, S. G., & Aiken, L. S. (2003). Applied multiple regression/correlation analysis for the behavioral sciences (3rd ed.). Erlbaum.
  • Johnson, P. O., & Neyman, J. (1936). Tests of certain linear hypotheses and their application to some educational problems. Statistical Research Memoirs, 1, 57–93. (No digital object identifier: the series predates them.)
  • Klein, A., & Moosbrugger, H. (2000). Maximum likelihood estimation of latent interaction effects with the LMS method. Psychometrika, 65(4), 457–474. https://doi.org/10.1007/BF02296338
  • Muthén, L. K., & Muthén, B. O. (2015). Version 7.4 Mplus language addendum. Muthén & Muthén. (No digital object identifier.) https://www.statmodel.com/download/Version7.4LanguageAddendum.pdf
  • Muthén, L. K., & Muthén, B. O. (2017). Mplus user’s guide (8th ed.). Muthén & Muthén.
  • Preacher, K. J., Curran, P. J., & Bauer, D. J. (2006). Computational tools for probing interactions in multiple linear regression, multilevel modeling, and latent curve analysis. Journal of Educational and Behavioral Statistics, 31(4), 437–448. https://doi.org/10.3102/10769986031004437
  • Wen, Z., Marsh, H. W., & Hau, K.-T. (2010). Structural equation models of latent interactions: An appropriate standardized solution and its scale-free properties. Structural Equation Modeling, 17(1), 1–22. https://doi.org/10.1080/10705510903438872