Help file for the command postgr --------------------------------
Syntax ------
postgr xvar, [ by(varname) x(vars-vals) asis(varlist) rest( > value) predict(varname) generate(varname) connect(connect options) gropts(graph options) outcome( > #) table table2 ]
postgr allows you to create graphs of predicted values after a Stata estimation command (e.g. regress, logistic, probit). postgr graphs the predicted values by xvar, holding all other variables constant at specified values (defaulting to the mean). You can show the predcted values separately for each level of the variable specified in the by option.
Options -------
by() - To show a graph separated by a categorical variable, include the by option.
x() - To hold some predictors constant at a certain value, include the x option. This sets the values of the predictors for calculating predicted values. The list must alternate variable names and values. The values may be either numeric values or can be mean, median, min, max, previous, upper, or lower. The latter cannot be used if rest() specifies a group summary statistic (e.g., grmean).
asis() - Variables to be left as is when creating predicted values. If categorical variables are used for the xvar or by variable, we recommend using "xi2" for estimating the model because postgr will automatically include xvar, by and their interaction (if present) without the need to specify the asis option.
If xi2 is not used to estimate the model, then you should include xvar, the by variable and interaction of xvar and by (if present). If any of these terms are omitted, the results could by adjusted for terms that you would like to remain as is.
rest() sets the independent variables not specified in x() to their mean (default), minimum, maximum, median when calculating predicted values. grmean sets these independent variables to the mean conditional on the variables and values specified in x(); grmedian, grmax, and grmin can also be used. If prvalue has already been run after the last estimate, previous will set unspecified variables to their prior values. For models other than mlogit, upper and lower can be used to set independent variables to their minimum or maximum depending on which will yield the upper or lower extreme predicted value.
predict() - This allows you to specify the kind of predicted value that is generated and plotted, for example xb , pr etc.. This would be the value that you would specify after the predict , command.
gen() - To save the predicted values, include the gen option and the predicted values will be saved as the variable name specified. If the by option is included, then additional variables will be saved that contain the predicted value broken down by the by variable.
connect() - To specify how the lines are connected, specify the connect option, e.g. connect(l) would connect the lines with straight lines or connect(ss) would connect 2 lines with splines. The postgr command attempts to automatically choose a connection style that makes most sense, but can be overridden with the connect option.
gropts() - The gropts option allows you to specify graph options for the graph command.
outcome() - When using ologit, oprobit, gologit, mlogit, or other estimation command with multicategory outcomes, you can use the outcome option to specify which outcome is to be considered.
table - This option creates a table of predicted values with the xvar on the rows and the by variable on the columns. If just the xvar is specified, the predicted values are just broken down by the xvar. This table is most readable when the xvar has many values (e.g. is continuous).
table2 - This option creates a table of predicted values with the xvar on the columns and the by variable on the rows (the reverse of the table option. This makes a table that more naturally corresponds to the graph produced when the xvar and by variable are both categorical.
Examples --------
use https://stats.idre.ucla.edu/stat/stata/notes/hsb2, clear gen hon = read > 60
* logit with single predictor logit hon socst postgr socst
* regress with single predictor regress read socst postgr socst
* logit with two predictors, show by "female" logit hon female socst postgr socst, by(female) asis(socst female)
* logit with two predictors, show by "female", using xi2 xi2: logit hon i.female socst postgr socst, by(female)
* logit with two predictors, show by "female", using xi2 xi2: logit hon i.female*socst postgr socst, by(female)
* logit with two predictors and additional covariates xi2: logit hon i.female*socst write math science postgr socst, by(female)
* like above, but uses "ses" with 3 levels and holding science at 65 xi2: logit hon i.ses*socst math science postgr socst, by(ses) x(science=65)
* including interaction of 2 categorical variables xi2: logit hon i.ses*i.female socst science postgr ses, by(female)
* regression with interaction of 2 categorical variables xi2: regress read i.ses*i.female socst science postgr ses, by(female) gen(adjmean) * show adjusted means by ses and female tabulate ses, summ(adjmean0 ) tabulate ses, summ(adjmean1 )
* regression with categorical by continuous interaction xi2: regress read i.ses*socst science postgr socst, by(ses)
* quantile regression xi2: qreg read i.ses*i.female science postgr ses, by(female)
Author ------ Michael Mitchell Academic Technology Services UCLA mnmatucla.edu
Credits ------- This program was inspired by the spostado utilities developed by J. Scott Long and Jeremy Freese. This program calls a modified version of _pebase (called _pebase2 for generating the x and rest values.
Also see -------- For more information about the 'spostado' package by J. Scott Long and Jeremy Freese, see www.indiana.edu/~jsl650/spost.htm .