Help file for the command postgr3 ---------------------------------
postgr3 xvar, [ by(varname) sep(varname) x(vars-vals) asis(varlist) rest(value) predict(varname) generate(varname) connect(connect options) outcome(#) table table2 graph options ]
postgr3 allows you to create graphs of predicted values after a Stata estimation command (e.g. regress, logistic, probit). postgr3 graphs the predicted values by xvar, holding all other variables constant at specified values (defaulting to the mean). You can show the predcted values as separate lines for each level of the variable specified in the by option. In addition to the by option you can also include the sep option to further separate the values into separate graphs.
VERY IMPORTANT NOTE! --------------------
The postgr3 command is based upon utilities contained in the spostado suite of tools developed by J. Scott Long and Jeremy Freese. For postgr3 to work, you need to install spostado by typing
. net from http://www.indiana.edu/~jslsoc/stata . net install spost9_ado
There are some models where postgr3 does not properly compute the estimates shown in the graphs and tables. Consider the model
. xi3: regress read g.female*g.ses g.female*g.race
Because female is involved in two interactions (interacting with ses and race, postgr3 does NOT properly compute the estimates for effects involving female. So the effects from this command will be incorrect
. postgr3 ses, by(female)
. postgr3 ses, by(race)
will also be incorrect. I am very sorry, but we do not have the time to overhaul postgr3 to accommodate these kinds of effects.
by() - To show a graph with separate lines based on a categorical variable, include the by option.
sep() - When using the by option, you can further break the results down by another categorical variable with the sep option. The sep option cannot be used without 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 "xi3" for estimating the model because postgr3 will automatically include xvar, by and their interaction (if present) without the need to specify the asis option.
If xi3 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 postgr3 command attempts to automatically choose a connection style that makes most sense, but can be overridden with the connect option.
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.
graph options - Here you can specify graph options for the graph command.
use https://stats.idre.ucla.edu/stat/stata/notes/hsb2, clear gen hon = read > 60
* logit with single predictor logit hon socst postgr3 socst
* regress with single predictor regress read socst postgr3 socst
* logit with two predictors, show by "female" logit hon female socst postgr3 socst, by(female) asis(socst female)
* logit with two predictors, show by "female", using xi3 xi3: logit hon i.female socst postgr3 socst, by(female)
* logit with two predictors, show by "female", using xi3 xi3: logit hon i.female*socst postgr3 socst, by(female)
* logit with two predictors and additional covariates xi3: logit hon i.female*socst write math science postgr3 socst, by(female)
* like above, but uses "ses" with 3 levels and holding science at 65 xi3: logit hon i.ses*socst math science postgr3 socst, by(ses) x(science=65)
* including interaction of 2 categorical variables xi3: logit hon i.ses*i.female socst science postgr3 ses, by(female)
* regression with interaction of 2 categorical variables xi3: regress read i.ses*i.female socst science postgr3 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 xi3: regress read i.ses*socst science postgr3 socst, by(ses)
* quantile regression xi3: qreg read i.ses*i.female science postgr3 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 .