*! version 1.0 12feb2016
{…}

help marhis Enrique Hernández

Predictive margins and marginal effects plots with histogram in the back after regress, logit, xtmixed and mixed.

Syntax

marhis
indepvar
[ , ]
[ mar(varname) ]
[ cate(varname) ]
[ points(#) ]
[ percent ]
[ discrete ]
[ level(#) ]
[ label(#) ]
[ summaryno ]
[ confidenceno ]
[ atmeans ]

Description

Following some of the recommendations of Berry, Golder and Milton (2012) marhis generates predictive margins and marginal effects
plots with a histogram summarizing the distribution of the variable on the x-axis in the back. marhis can be used after regress, logit, xtmixed or mixed.

marhis can be used to graph the adjusted predictions of any continuous variable in the model (A), to graph the results of an interaction
between two continuous variables (B), or to graph the results of an interaction between a continuous and a categorical variable (C). Interactions must always be specified using factor
variable notation in the regression model but not in the marhis command.

marhis does not require the user to run the margins command since the estimations of the marginal effects or marginal predictions are
handled directly by marhis relying on the margins command. A summary of the margins specification used by marhis is presented to the user in the results window.

A) Plotting average adjusted predictions (AAPs) of the dependent variable across the range of any continuous independent variable included in the regression model. The marhis command should
be specified as follows:

. marhis indepvar

where indepvar is the continuous covariate to be placed on the x-axis and across which the average adjusted predictions of the dependent variable will be estimated.
The range of indepvar is determined by the minimum and maximum value of indepvar for the cases included in the regression model.
By default the graph includes a note summarizing the coefficient and t-statistic of the plotted variable.

B) Plotting an interaction between two continuous variables. To plot the average marginal effects (AMEs) of one of the variables of the interactive term across the range of the second variable of the interactive
term the option mar(varname) must be specified. Therefore, marhis should be specified as follows:

. marhis indepvar , mar(varname)

where mar(varname) is the term of the interaction for which the average marginal effects will be estimated and plotted across the range of the second term of the
interaction indepvar which will be placed on the x-axis with a histogram summarizing its distribution in the back of the plot. By default the graph includes a note summarizing the coefficient
and t-statistic of the plotted interaction.

C) Plotting an interaction between a continuous and a categorical variable. To plot average adjusted predictions of the dependent variable for each of the categories of the categorical term of the
interaction across the range of the continuous term of the interaction the option cate(varname) must be specified. Therefore, marhis should be specified as follows:

. marhis indepvar , cate(varname)

where cate(varname) is the categorical term of the interaction and indepvar is the continuous term of the interaction. Average adjusted predictions of the dependent variable will be plotted
for each of the cattegories of cate(varname) across the range of the continous term of the interaction indepvar, which will be placed on the x-axis with a histogram summarizing its distribution in the
back of the plot. The values of the categorical term of the interaction cate(varname) must always be labelled before using marhis (labels might be numeric). Only categorical
variables with 5 or fewer categories are currently supported.

Options

mar(varname) plot marginal effect of the variable specified. Must be used to plot the results of an interaction between two continuous variables.

cate(varname) defines the categorical term of the interaction to be plotted. Must be used to plot the results of an interaction between a categorical and continuous variable.

points(#) set the number of data points to be estimated by the margins command between the minimum and maximum value of the variable on the x-axis; default level is 15. Larger numbers increase the
smoothness of the plotted results but increase computation time.

percent draw histogram of indepvar as percentages; default is density.

discrete specify that indepvar is discrete (only affects rendition of the histogram).

level(#) set confidence interval level; default is level(95).

label(#) modify the number of labels (values) displayed on the x-axis between minimum and maximum value of indepvar; default is 4

summaryno suppresses the note with the summary of the coefficient of the variable or interactive term included in the graph.

confidenceno suppresses the confidence intervals in the plotted results.

atmeans estimate margins at the means of covariates; by default average adjusted predictions or average marginal effects are estimated.

Examples

. webuse nhanes2.dta

A) Average adjusted predictions of having high blood pressure across the range of a continuous predictor (height in cm).

. logit highbp age weight height

. marhis height

B) Interaction between two continuous variables (age and height) (dependent variable having high blood pressure). Average marginal effects of age across values of height.

. logit highbp c.age##c.height weight

. marhis height, mar(age)

C) Interaction between a continuous (age) and a categorical variable (sex). Average adjusted predictions of having high blood pressure for different categories of sex across values of age.

. logit highbp c.age##i.sex weight height

. marhis age, cate(sex)

References

Berry, W. D., Golder, M., & Milton, D. (2012). Improving tests of theories positing interaction. Journal of Politics, 74(3), 653-671.

Acknowledgments

I would like to thank Macarena Ares, Albert Arcarons and Guillem Vidal for their useful comments and suggestions. I would also like to thank the
statalist users who answered my questions and provided valuable suggestions. I would also like to acknowledge the use of the code to save
labels in macros proposed by Matt Spittal in statalist.

Author

Enrique Hernández, SPS department, European University Institute. Please report bugs and suggestions to Enrique.Hernandez@EUI.eu