Marginal or Conditional Effects Plots by using Stata

Plotting the adjusted marginal or conditional effects helps to understand and communicate what a logistic model implies about probabilities. For example, we could find the predicted probability of any thermal distress incidents as a function of temp, holding date constant at relatively low (early) and high (late) values.

Elapsed dates in these data range from the first shuttle flight on April 12, 1981 (date = 7772) to the fatal Challenger launch on January 21, 1986 (date = 9524). Joint temperatures range from 31 to 81 degrees Fahrenheit. margins can calculate and marginsplot graph the predicted probabilities from our logistic model at 10-degree increments in temperature, at the earliest and latest dates.

The default marginsplot graph in Figure 9.2 conveys basic information, but is not pretty. For a more publishable version we could suppress the confidence intervals (noci), relocate the legend, use plot#opts() to visually distinguish the two curves, and add a title. First, we run margins again with one-degree increments in temperature, which will make the resulting curves smoother.

. quietly margins, at(temp = (30(1)80) date = (8000 9500))

. marginsplot, noci legend(position(7) ring(0) rows(2))

plot1opts(msymbol(i) lpattern(dash) lwidth(medthick))

plot2opts(msymbol(i) lpattern(solid) lwidth(medthich))

title(“Predicted probability of booster O-ring damage”)

According to our logistic model, around the time of the earliest shuttle flight (dashed curve in Figure 9.3) the probability of thermal distress goes from near zero at 80 °F, to near one below 40 °F. By the time ofthe Challenger flight (solid curve), however, the probability of any distress exceeds .6 even in warm weather, and climbs toward one on flights below 70 °F. Note that Challenger’s actual temperature at launch, 31 °F, would place it at top left in Figure 9.3.

Source: Hamilton Lawrence C. (2012), Statistics with STATA: Version 12, Cengage Learning; 8th edition.

Leave a Reply

Your email address will not be published. Required fields are marked *