Credit portal




Welcome to the Institute for Digital Research and Education

Stata FAQ

How can I graph the results of the margins command? (Stata 12)

Graphing results from the margins command can help in the interpretation of your model. Stata 12 introduced the marginsplot command which make the graphing process very easy.

Let's start off with an easy example.

Example 2

For our second example we will graph the results of a categorical by continuous interaction from a logistic regression model. We will use the margins command to get the predicted probabilities for 11 values of s from 20 to 70 for both f equal zero and f equal one. The vsquish option just reduces the number of blank lines in the output. In total, there are 22 values in the above table. There are two predicted probabilities for each value of s. One each for males and females.

Now we can go ahead and graph the probabilities using the marginsplot command. This time we will include the default confidence intervals. We

can make the graph more visually attractive by shading the area inside the confidence intervals. The graph of the probabilities above is nice as far as it goes but the presentation of the results might be clearer if we were to graph the difference in probabilities between males and females. To do this we will need to rerun the margins command computing the discrete change for f at each value of read. We can get the difference using the dydx (derivative) option. Everything is ready for the marginsplot command. As nice as the above graph is, it might look better done as a range plot with area shading between the upper and lower confidence bounds. If you want the lines in these graphs to be smoother, just include more values in the at option, say (20(2)70) instead of (20(5)70).

The content of this web site should not be construed as an endorsement of any particular web site, book, or software product by the University of California.

Category: Bank

Similar articles: