*! version 1.0 2/27/2018

Title

outdisp -- creates tables or graphs of the observed or "modeled" outcome showing how it varies with a set of interacting predictors
with options to unpack the confounded non-linearities of interactions with prediction functions for generalized linear models.

Description

outdisp produces tables and/or bar charts, scatterplots or contour plots displaying the pattern of the relationship between
interacting prdictors and the observed or "modeled" outcome. Bar charts and scatterplots can optionally superimpose main effects model
predictions on the graphs of predicted values from the interaction model. Plots of the modeled outceoem can show dual-axis labelling
in modeled and observed metrics. Must run intspec before running outdisp.
See Kaufman (2018) for detailed explanation and step-by-step examples of using this and other ICALC add-on commands.

Syntax

outdisp , [ outcome:(metric(predtype) atopt(marginspec) sdy dualaxis mainest(estname))
plot(type(plottype) single(detail) name(graphname) save(filepath) freq(base)
keepfrq ccuts(numlist))) table(rowvar(type) save(filepath) freq(base) abs)
ndigits(#) pltopts(string) ]

options Description

outcome(metric(predtype) suboptions) get predictions in observed or modeled metric, prediction and display suboptions

metric(predtype) plottype is obs for observed metric (default), model for modelled metric

suboptions

atopt(marginspec) Specify content for the at( ) option of the margins command for predictors other than focal
or moderators. Default atopt((asobs) _all)

sdy keyword sdy valid only with metric(model). Labels the primary y-axis in model metric standard
deviation units (if applicable)

dualaxis keyword dualaxis valid only with metric(model). Adds a 2nd y-axis labelled in the observed outcome metric.
Not valid for mlogit

mainest(estname) valid only with metric(obs). Adds main effects predictions to interaction effects display.
Must have used estimates store estname to save main effects model estimates.

plot(type(plottype) suboptions) specifies how to plot outcome varying with the focal and moderating variables

type(plottype) plottype is keyword for type of plot

scat for scatterplot, default if focal is interval

bar for bar chart, default if focal is categorical

contour for contour plot, only if focal & 1st moderator are interval

suboptions

name(graphname) save plot as memory graph with name graphname

single(detail) detail is # or keyword for what is shown on single graph

1 show separate outcome-focal plots for each display value of moderator#1

2 show all moderator#1 results on same outcome-focal plot but a single graph for each display value of moderator#2

all show separate outcome-focal plots for each combination of moderator#1 and moderator#2 display values

save(filepath) save plotting data & frequency distribution to Excel file with name & location given by filepath

freq(base) add relative frequency distribution of 1st moderating variable or 1st by 2nd moderator to the plot

base can be

tot for distribution of 1st moderator

sub for distribution of the 1st moderator within levels of the 2nd

subtot for joint distribution of the 1st & 2nd moderators relative to total sample size

keepfreq save the separate frequency distribution graphs used to create final frequency graph

table(suboptions)) make table of predicted outcome by focal & moderating variables

suboptions

rowvar(type) keyword type = focal or mod to define table rows. Default rowvar(focal)

save(filepath) same as for plot suboptions

freq(base) same as for plot suboptions

ndigits(#) number of digits for y-axis labels Default = 4.

ccuts(numlist) numlist defines contour cutpoints. Default is 6 equal steps from min to max of predicted outcome.

pltopts(string) string contains two-way graph options to customize appearance (e.g. line colors). These do not always work as expected.
Use the graph editor if not.

Note: Focal and moderator range( ) define display values/labels on axis plotting focal variable (contour plots: also for 1st moderator).
For tables, sets display values/labels of row and column. For both plots and tables, moderators’ range( ) defines calculation points
at which the plot or table calculations are repeated.

Example: two-way interaction

For a model predicting poor mental health days (pmhdays) by the interaction of work-family conflict (wfconflict)
and job status (sei), intspec specfies wfconflict as the focal variable and sei as its moderator. outdisp
produces a scatterplot of the predicted count for pmhays against wfconflict with separate prediction curves for each of the 5 display value of sei (17, 37, 57, 77, 97), the default plot type.

nbreg pmhdays c.wfconflict##c.sei ...

intspec, focal(c.wfconlifct) main( (c.sei name(JobStatus) range(17(20)97)) (c.wfconflict name(WorkFamConflict) range(1/4))) int2vars(c.wfconflict#c.sei)

outdisp , plot(type(scat)) ndigits(2)

*** Add superimposed main effects plot from model estimates stored in mymainmod

outdisp , plot(type(scat)) outcome(main(mymainmod)) ndigits(2)

*** Change to modelled outcome (ln count) metric

outdisp , plot(type(scat))) outcome(metric(model)) ndigits(2)

*** Add 2nd y-axis labelled as count to primary y-axis labelled as log count

outdisp , plot(type(scat))) outcome(metric(model) dualaxis) ndigits(2)

*** Change plot type to contour

outdisp , plot(type(cont))) outcome(metric(model) dualaxis) ndigits(2)

Note that for a three-way interaction outdisp creates repeated plots of the predicted outcome
against the focal variable with separate prediction curves for each display value of the first moderator.
This plot is repeated for each display value of the second moderator.

Author and Citation

I would appreciate users of this and other ICALC commands citing

Robert L. Kaufman. 2018. Interaction Effects in Linear and Generalized Linear Models, Sage Publcations.