help for modplot

Title

modplot —— Plotting graphs of moderating effects.

Syntax

modplot,
model:(command dependentvar independentvar moderatevar controlvars, options)
[
plot:
dot:
right:
scheme:(schemename)
other_opts
]

Description

The modplot will help you plot the moderating effects in one click,
but you need to be aware that the picture will only be available if
you have used the plot option. Otherwise the default will only store the
equation for the moderating effect in the return value.

Options

model(command dependentvar independentvar moderatevar controlvars, options)
specifies your regression model. Note that this command does not support
if and in, and also automatically records the second
variable in your model as the independent variable and the third variable
as the moderator variable.

plot: specifies whether the corresponding moderating effects
need to be plotted.

dot: specifies whether solid points need to be added to the
ends of the line graph in the image.

right: specifies whether the legend needs to be placed to the
right of the image.

scheme:(schemename)
Specifies the drawing style of the image. You can click on the blue
hyperlinks to see the styles available for your Stata.

other_opts you can add other plotting options here, such as title("this is a title")

Results

After running modplot, the marginal equations for the moderating
effects will be recorded in the return values, which you can view using
the return list. Also, if you use the plot option, then a plot of the
moderating effects will be generated. Note that the dot option, the
right option, and the scheme option are used to further embellish the picture.

Code examples

*- Both the independent and moderator variable are binary variables.

-
`"sysuse bplong.dta, clear"'

-
`"modplot, model(reg bp sex when agegrp, vce(r)) plot dot scheme(s1mono)"'

*- The independent variable is a binary variable but the moderator
variable is a continuous variable.

-
`"sysuse auto.dta, clear"'

-
`"modplot, model(reg price foreign length weight, vce(r)) plot dot scheme(s1mono)"'

*- The independent variable is a continuous variable but the moderator
variable is a binary variable.

-
`"sysuse auto.dta, clear"'

-
`"modplot, model(reg price length foreign weight, vce(r)) plot dot scheme(s1mono)"'

*- Both the independent and moderator variable are continuous variables.

-
`"sysuse auto.dta, clear"'

-
`"modplot, model(reg price weight length foreign, vce(r)) plot dot scheme(s1mono)"'

*- Other plotting options (added by Professor Christopher F. Baum)

-
`"sysuse auto.dta, clear"'

-
`"modplot, model(reg price foreign length weight, vce(r)) plot ti("Effects of length")"'

-
`"modplot, model(reg price foreign length weight, vce(r)) plot ti("Effects of length", box) legend(rows(1) size(small))"'

*- Additionally, you can use other regression estimators for regression.
modplot theoretically supports regression methods where all coefficients
are stored in the e(b) matrix and with coefficient term.

Author

Basic information

Name: Shutter Zor (左祥太)

Affiliation: Accounting Department, Xiamen University.

E-mail: Shutter_Z@outlook.com

Other information

Blog: blog link

Bilibili: 拿铁一定要加冰

WeChat Official Account: OneStata

Other commands i have written

oneclick (if installed) ssc install oneclick (to install)

onetext (if installed) ssc install onetext (to install)

econsig (if installed) ssc install econsig (to install)

wordcloud (if installed) ssc install wordcloud (to install)

Acknowledgments

Thanks to Bilibili users (导导们). Thanks to Professor Christopher F. Baum for the
information that gave me a better understanding of Stata programming.