help for oprobpr                                                    Nick Winter

Displaying predicted probabilities from ordered probit & logit

oprobpr yvar xvar [weight] [if exp] [in range] [, adjust(varlist) xact(varlist) poly(#) from(#) to(#) inc(#) plot(pspec[, ...]) symbol(s...s) connect(c[[p]] ... c[[p]]) labels(lab[, ...]) keys text(x y text [\...]) cmd(cmd_name) nolist noplot nomodel save(filename[, replace])} modeloptions(options) graph_options


oprobpr estimates an ordered dependent variable model on a continuous X variable and an optional set of covariates, then lists and graphs the predicted probabilities from this model against the X variable, holding the covariates constant. Optionally, quadratic or quadratic and cubic terms can be added to the model, as well as interaction terms between X and one or more other covariates.

By default all response categories are listed and plotted; the plot() option allows the user to control plotting of only some categories, or combinations of categories. labels() allows control of the labelling of the plotted lines.

oprobpr is originally based on logpred published by Joanne Garrett and of probpred published by Mead Over in sg42.2: STB 42. Unlike those commands, oprobpr, does not include confidence intervals in the list or graph.


adjust(varlist) specifies the other covariates in the model. For the calculation of probabilities, by default these are set to their mean, based on the observations used in the analysis. They can be set to other values, e.g. a(mpg=50 foreign=1 weight).

xact(varlist) indicates that the variables in varlist (a subset of adjust()) should also enter the model in interaction with xvar. The interaction terms are created and entered in the model automatically.

poly(#) indicates that xvar enters the model as a polynomial. Quadratic and cubic models are allowed. They are indicated by poly(2) and poly(3), respectively. The polynomial terms are created and entered in the model automatically.

from(#) specifies the lowest value of xvar for which a prediction is to be calculated. The default is to use the minimum of xvar in the data.

to(#) specifies the highest value of xvar for which a prediction is to be calculated. The default is to use the maximum of xvar in the data.

inc(#) specifies the increment between adjacent values of xvar. The default is to set an increment such that eleven probabilities are calculated.

plot(n,...,n) controls which categories of the dependent variable are plotted and listed. The default is to list and plot probabilities for all categories. For example, p(1,3,4) would result in categories 1, 3 and 4 only being listed and plotted.

plot() also allows categories to be combined. So, for example, p(1+2,3,4+5+6) would plot three lines: one that is the sum of probabilities for categories one and two, one that is the probability of category three, and one that is the sum of categories 4 through 6.

symbol() indicates what symbol should be used for the lines. The syntax is identical to the graph command's symbol() option. By default, the lines have no symbols.

connect() specifies the line style with which to draw the lines. The default is to connect cubic splines with solid lines. The syntax is identical to the graph command's connect() option.

labels() specifies text labels with which to label the lines. By default, simple categories are labeled with the appropriate value label from the dependent variable, if available. Otherwise, they are labelled "Cat 1", "Cat 2" ... , through "Cat n". For example, s(Low,Medium,High) would label the lines "Low", "Medium", and "High". To leave a line unlabeled, indicate a "." for its label.

text() specifies lines of text to be added to the graph. X and y coordinates should be specified in terms of the graph metric, followed by the text to be inserted. Multiple text specifications may be separated with a backslash, e.g. text(24 .6 First string \ 30 .2 More text) would insert "First string" at 24,0.6 and "More text" at 30,0.2 on the graph.

keys specifies that Stata's default graph keys should be displayed, rather than the default title line. Note that specific keys can be specified manually with the key1 through key4 options, and titles may be specified manually with the t1title and t2title options.

command specifies the estimation command to be used. Valid options are oprobit, ologit, svyoprobit, and svyologit. The default is oprobit.

nomodel suppresses the display of the estimated model.

nolist suppresses the list of predicted values.

noplot suppresses the graph of predicted values.

save(filename) saves the prediction data set. This is useful for conducting additional analysis of the predicted values. (Note that the graph option saving() is different, and may be used to save the resulting graph.)

modeloptions specifies options to be included in the running of the model, such as robust.

graph_options can be any valid options for a twoway graph. Particularly helpful are xlabel, ylabel, saving(filename), titles, and the rest.


. oprobpr rep78 mpg, adj(weight gear_ratio foreign) noplot

Calculates the predicted probabilities of 1978 repair ratings (rep78) for various values of mpg, adjusted for weight, gear ratio and foreign; mpg ranges in 10 steps according to its minimum and maximum in the data; displays model and predicted values but not the graph.

. oprobpr rep78 mpg, adj(weight gear_ratio foreign=0)

Same as above, except predictions are for foreign==0 instead of for the sample average of foreign. Graph and predictions are displayed.

. oprobpr rep78 mpg, adj(weight gear_ratio foreign=0) xact(weight) poly(3) cmd(olog)

Same as above, except that the interaction term weight*mpg is included in the model using the xact(weight) option, and terms for mpg-squared and mpg-cubed are included using poly(3). Model estimated is ordered logit rather than ordered probit.

. oprobpr rep78 mpg, adj(weight gear_ratio foreign=0) p(1,3+4,5) lab(Low,Med&High,Very High) c(s[.] s[-] s) ylab(0,.5,1)

Same as above but only lists and plots categories 1, the sum of 3 and 4, and 5 of rep78, and labels them "Low", "Med&High", and "Very High", respectively. The connect() options indicates that the first two lines are drawn with short and long dashes, and the ylabel() option labels the y-axis appropriately for predicted probabilities. Note that any other option which works on the graph command will also work here.

. oprobpr rep78 mpg, f(30) t(50) adj(weight gear_ratio) xlab ylab nolist

Calculates the predicted probability over the range 30 to 50 of mpg, rather than the range of mpg in the data set. Displays the model and the graph, but omits the list of predictions.


Nick Winter Cornell University nw53@cornell.edu

Also see

STB: STB-42 sg42.2, STB-26 sg42, STB-24 sg33 Manual: [R] oprobit, oprobitp, ologit, ologitp On-line: help for predict, oprobit, ologit, probpred (if installed), regpred2 (if installed), logpred (if installed), adjmean (if installed), adjprop (if installed)