This example uses the hsb2 data file to illustrate how to graph predicted probabilities based on a logistic regression model with an interaction of a binary variable with a continuous variable. .
use https://stats.idre.ucla.edu/stat/stata/notes/hsb2, clear gen hiwrite = (write>60) xi: logit hiwrite i.female*math read mat c=e(b) /*storing the regression coefficients*/ sum read preserve clear set obs 3 gen read = r(mean) in 1 replace read = r(mean) + r(sd) in 2 replace read = r(mean) - r(sd) in 3 gen group = _n expand 2 /*for two values of gender*/ sort read by read: gen female = _n -1 sort read female expand 20 /*for 20 values of math going from 32 all the way to 70*/ sort read female by read female: gen math = 2*_n + 30 gen fmath = female*math /*interaction term*/ gen one = 1 mkmat female math fmath read one, mat(X) mat pred = X*c' /*linear prediction*/ svmat pred gen p = exp(pred)/(1+exp(pred)) /*probability*/ twoway (line p math if female==1 & group==1) (line p math if female==0 & group==1) restore