help coefplothttp://repec.sowi.unibe.ch/stata/coefplot http://github.com/benjann/coefplot ---------------------------------------------------------------------------------------Titlecoefplot-- Plotting regression coefficients and other resultsSyntaxcoefplotsubgraph[ ||subgraph|| ... ] [,globalopts] wheresubgraphis defined as(plot)[(plot)... ] [,subgropts] andplotis either_skip(to skip a plot) ormodel[ \model\ ... ] [,plotopts] andmodelisnamelist[,modelopts] wherenamelistis a list of names of stored models (see helpestimates; type.or leave blank to refer to the active model). The*and?wildcards are allowed innamelist; seeUsing wildcards in model names. Furthermore,modelmay also bematrix(mspec)[,modelopts] to plot results from a matrix (seePlotting results from matricesbelow). Parentheses aroundplotcan be omitted ifplotdoes not contain spaces.modeloptsDescription --------------------------------------------------------------------------------- Mainomittedinclude omitted coefficientsbaselevelsinclude base levelsb(mspec)specify source to be plotted; default is to plote(b)at[(spec)] get plot positions frome(at), or as specified byspeckeep(coeflist)keep specified coefficientsdrop(coeflist)drop specified coefficients Confidence intervalsnociomit confidence intervalslevels(numlist)set level(s) for conficence intervalsci(spec)provide confidence intervalsv(name)provide variances; default is to usee(V)se(mspec)provide standard errorsdf(spec)provide degrees of freedomcitype(method)method to compute confidence intervals; default iscitype(normal)Transform resultseform[(coeflist)] plot exponentiated point estimates and confidence intervalsrescale(spec)rescale point estimates and confidence intervalstransform(matchlist)transform point estimates and confidence intervals Names and labelsrename(spec)rename coefficientseqrename(spec)rename equationsasequation[(string)] set equation to model name orstringswapnamesswap coefficient names and equation namesmlabels(matchlist)add custom marker labels Auxiliary resultsaux(mspec[mspec...])make additional results available as@aux1,@aux2, etc. ---------------------------------------------------------------------------------plotoptsDescription --------------------------------------------------------------------------------- Passthrumodeloptsplot-specific model options; seePlacement of optionsMainlabel(string)label to be used for the plot in the legendkey[(ci[#])] key symbol to be used for the plot in the legendnokeydo not include the plot in the legendpstyle(pstyle)overall style of the plotaxis(#)choice of axis for the plot,1<#<9offset(#)provide offset for plot positionsif(exp)restrict the contents of the plotweight(exp)scale size of markers Markersmarker_optionschange look of markers (color, size, etc.)mlabel[(spec)] add marker labelsmarker_label_optionschange the look and position of marker labelsrecast(plottype)plot results usingplottypeConfidence spikescionlyplot confidence spikes onlycitopdraw confidence spikes in front of markerscirecast(plottype)shorthand forciopts(recast())ciopts(options)affect rendition of confidence spikescismooth[(options)] add smoothed confidence intervals ---------------------------------------------------------------------------------subgroptsDescription --------------------------------------------------------------------------------- Passthrumodeloptssubgraph-specific model options; seePlacement ofoptionsplotoptssubgraph-specific plot options; seePlacement ofoptionsMainbylabel(string)label to be used for the subgraph ---------------------------------------------------------------------------------globaloptsDescription --------------------------------------------------------------------------------- Passthrumodeloptsglobal model options; seePlacement of optionsplotoptsglobal plot options; seePlacement of optionssubgroptsglobal subgraph options; seePlacement of optionsMainhorizontalcoefficient values are on x axis; general defaultverticalcoefficient values are on y axis; default withat()eqstrictbe strict about equationsorder(coeflist)order coefficientsorderby(spec)order coefficients by specific modelsort[(spec)] sort coefficientsrelocate(spec)assign specific positions to coefficientsbycoefsarrange subgraphs by coefficientsnorecycleincrement plot styles across subgraphsnooffsetsdo not offset plot positionsformat(format)set the display format for numeric labelsp#(plotopts)options for#th plot Labels and grid linesnolabelsuse variable names instead of labelscoeflabels(spec)specify custom labels for coefficientsnoeqlabelssuppress equation labelseqlabels(spec)specify labels for equationsheadings(spec)add headings between coefficientsgroups(spec)add labels for groups of coefficientsplotlabels(spec)(re)set plot labelsbylabels(spec)(re)set subgraph labelsgrid(options)affect rendition of grid lines Save resultsgenerate[(prefix)] generate variables containing the graph datareplaceoverwrite existing variables Add plotsaddplot(plot)add other plots to the graphnodropdo not drop observations Y axis, X axis, Titles, Legend, Overall, Bytwoway_optionstwoway options, other thanby()byopts(byopts)how subgraphs are combined ---------------------------------------------------------------------------------Descriptioncoefplotplots results from estimation commands or Stata matrices. Results from multiple models or matrices can be combined in a single graph. The default behavior ofcoefplotis to draw markers for coefficients and horizontal spikes for confidence intervals. However,coefplotcan also produce various other types of graphs.+---------------+ ----+ Model options +------------------------------------------------------------Optionsomittedincludes omitted coefficients. This may be useful if a model contains coefficients that have been dropped due to collinearity.baselevelsincludes base levels of factor variables.b(mspec)specifies the source from which the point estimates and coefficient names are to be collected. The default is to use (the first row of)e(b)(ore(b_mi)if plotting results frommi estimate).b()is discarded in matrix mode (seePlotting results from matricesbelow).mspecmay be:nameuse first row ofe(name)name[#,.]use #th row ofe(name); may also typename[#,]orname[#]name[.,#]use #th column ofe(name); may also typename[,#]at[(spec)] causes plot positions to be determined by the values ine(at)(or matrixat) or as specified byspec. The default is to create a categorical axis with coefficients matched by their names. However, ifatis specified, the axis is treated as continuous. Note that labeling optionscoeflabels(),eqlabels(),headings(), orgroups()are not allowed ifatis specified. Also not allowed withatare optionsbycoefs,order(), andrelocate(). Furthermore, note thatathas to be specified for all models or for none.specis [atspec] [,transform(exp)] whereatspecmay bemspecas above forb()# use #th at-dimension (margins) or #th row/column of main matrixmatrix(mspec)read from matrix instead ofe()_coefuse coefficient names as plot positions_equse equation names as plot positions Ifatis specified without argument, the plot positions are taken from the first row ofe(at)(or matrixat). A special case are results frommarginswhere recovering the plot positions is more complicated. The default in this case is to use the first at-dimension. Type, e.g.,at(2)if multiple at-dimension were specified withmarginsand you want to use the second dimension. Furthermore, in matrix mode (seePlotting results from matricesbelow),at(2)would read the plot positions from the 2nd row (or column) of the main matrix. When plotting results frome()it is sometimes convenient to maintain an external matrix with the plot positions instead of adding plot positions to eache()-set. In this case you can use syntaxat(matrix(mspec))to read the plot positions. Note that the vector of plot positions must have the same length as the coefficient vectors of the plotted models; elements are matched by position, not by name. Furthermore,at(_coef)orat(_eq)will use the coefficient names or the equation names as plot positions, respectively. This is useful only if the coefficient names or the equation names are numeric. Note that you may userename()andeqrename()to strip a non-numeric prefix or suffix from coefficient names or equation names. Suboptiontransform()transforms the plot positions before creating the graph. Within the transformation expression, use@as a placeholder for the value to be transformed. For example, to take the antilogarithm of the plot positions typetransform(exp(@)).keep(coeflist)specifies the coefficients to be plotted. The default is to include all coefficients from the first (nonzero) equation of a model (and discard further equations).coeflistis a space-separated list of elements such as:coefkeep coefficientcoefeq:keep all coefficients from equationeqeq:coefkeep coefficientcoeffrom equationeqwhereeqandcoefmay contain "*" (any string) and "?" (any nonzero character) wildcards. For example, typekeep(*:)orkeep(*:*)to plot all coefficients from all equations. Ifeqis specified, it is applied to all subsequent names until a neweqis specified. For example,keep(3:mpg price 4:weight)will plot coefficients "mpg" and "price" from equation "3" and coefficient "weight" from equation "4".drop(coeflist)drops the specified coefficients, wherecoeflistis as above forkeep().nociomits confidence intervals.levels(numlist)sets the level(s), as percentages, for confidence intervals. Specified values may be between 10.00 and 99.99 and can have at most two digits after the decimal point. The default islevels(95)or as set bysetlevel. If multiple values are specified, multiple confidence intervals are plotted. For example, typelevels(99.9 99 95)to plot the 99.9%, 99%, and 95% confidence intervals. The default is to use (logarithmically) increasing line widths for multiple confidence intervals. This behavior is disabled as soon aslwidth()orrecast()is specified withinciopts().ci(spec)specifies the source from which to collect confidence intervals. Default is to compute confidence intervals for the levels specified inlevels()using variances/standard errors (and, possibly, degrees of freedom). Theci()option is useful to plot confidence intervals that have been provided by the estimation command (such as, e.g.,bootstrap).speciscispec[cispec...] wherecispecisnameto get the lower and upper confidence limits from rows 1 and 2 ofe(name)(or matrixname), respectively. Alternatively,cispecmay be(mspecmspec)to identify the lower and upper confidence limits, withmspecas above forb(). For example, afterbootstrap,ci(ci_bc)would get bias-corrected confidence intervals from rows 1 and 2 ofe(ci_bc). The same could be achieved byci((ci_bc[1] ci_bc[2])).cispecmay also be # for a specific confidence level as inlevels(). Hence, you may type, e.g.,ci(95 myci)to plot the usual 95% confidence intervals along with custom confidence intervals provided ine(myci). Levels specified inci()take precedence over levels specified inlevels()), however, you may also type""withinci()to leave a position blank an use the specified level fromlevels(). In matrix mode (seePlotting results from matricesbelow),cispecmay also be(# #). For example,ci((2 3))would read the lower confidence limit from the 2nd row (or column) and the upper confidence limit from the 3rd row (or column) of the main matrix.v(name)specifies that the variances for confidence interval computation are to be taken from the diagonal ofe(name)(or matrixname). Default ise(V)(ore(V_mi)if plotting results frommi estimate).se(mspec)provides standard errors to be used for computation of confidence intervals. Default is to compute confidence intervals based on the variances ine(V)(seev()above).mspecis as above forb(). In matrix mode (seePlotting results from matricesbelow), you may also specifyse(#)to read the standard errors from the #th row (or column) of the main matrix.df(spec)specifies degrees of freedom (DF) to be taken into account for confidence interval computation. Default is to obtain DF from scalare(df_r)if defined (as in, e.g.,regress) or, for results frommi estimate, from matrixe(df_mi). Otherwise, no DF are taken into account. Specifydf(spec)to provide custom DF.specmay be: # set DF for all coefficients to #mspecas above forb()citype(method)specifies the method to be used to compute the limits of confidence intervals.methodcan benormal,logit,probit,atanh, orlog.citype(normal), the default, computes confidence limits based on untransformed coefficients and standard errors. Letbbe the point estimate,sethe standard error, andtthe (1-a/2) quantile of the standard normal distribution or the t-distribution (if degrees of freedom are available; see above), whereais 1 minus the confidence level (e.g.a=5% for a 95% confidence interval). Then the limits of the confidence interval are computed asb+/-t*secitype(logit)uses the logit transformation to compute the limits of confidence intervals. This is useful if the estimates to be plotted are proportions and the confidence limits are supposed to lie between 0 and 1. The limits are computed as invlogit(logit(b) +/-t*se/ (b* (1 -b)))citype(probit)is an alternative tocitype(logit)and computes the limits as normal(invnormal(b) +/-t*se/ normalden(invnormal(b)))citype(atanh)uses the inverse hyperbolic tangent to compute the confidence intervals. This is useful for estimates that lie between -1 and 1, such as a correlation coefficient. The limits are computed as: tanh(atanh(b) +/-t*se/ (1 -b^2))citype(log)computes log-transformed confidence intervals. This is useful for estimates that may only be positive, such as a variance estimate. The limits are computed as: exp(ln(b) +/-t*se/b)eform[(coeflist)] causes point estimates and confidence intervals to be exponentiated. This is useful if you want to plot hazard ratios (HR), incidence-rate ratios (IRR), odds ratios (OR), or relative-risk ratios (RRR). Ifeformis specified without arguments, then all coefficients of the model are exponentiated. To exponentiate only selected coefficients, specifycoeflistas above forkeep().rescale(spec)rescales point estimates and confidence intervals. Typerescale(#)to rescale all coefficients by a constant factor. For example,rescale(100)will multiply all coefficients by 100. Alternatively,specmay becoeflist=# [coeflist=# ...] withcoeflistas above forkeep().transform(matchlist)transforms point estimates and confidence intervals.machlistis:coeflist= "exp"[coeflist= "exp"...] withcoeflistas above forkeep(). Within the transformation expression, use@as a placeholder for the value to be transformed. For example, to take the square root of all coefficients typetransform(* = sqrt(@)). In addition, internal variables may be used as explained in Accessing internal temporary variables. The transformation expression must be enclosed in double quotes if it contains spaces. If specified,eform()andrescale()are applied before applyingtransform().rename(spec)renames coefficients.specis:coeflist=newname[coeflist=newname...] [,regex] withcoeflistas above forkeep()except that wildcards are only allowed in equation names, and coefficient names may be specified asprefix*to replace a prefix or*suffixto replace a suffix. For example,rename(*.foreign =.cartype)will rename coefficients such as0.foreignand1.foreignto0.cartypeand1.cartype.newnamemust be enclosed in double quotes if it contains spaces. For labeling coefficients, also seecoeflabels(). Apply optionregexto cause coefficient specifications (but not equation specifications) to be interpreted as regular expressions. In this case,newnamemay contain\1, ...,\9to reference back to matched subexpressions (and\0for the entire match). For example, typerename(^AA([0-9]+)BB$ =YY\1ZZ, regex)to rename coefficients such asAA123BB,AA0BB, orAA99BBtoYY123ZZ,YY0ZZ, orYY99ZZ. If the leading^or the tailing$is omitted, only the matched part of a coefficient name is subject to substitution; the rest of the name will remain unchanged. Include the regular expressions in quotes or compound double quotes if they contain funny characters (such as, e.g., quotes, equal signs, or commas).eqrename(spec)renames equations.specis:eqlist=newname[eqlist=newname...] [,regex] whereeqlistis a space separated list of equation names. Equation names may beprefix*to replace a prefix or*suffixto replace a suffix. For example,eqrename(rep78* = reprec)will rename equations such asrep78_3andrep78_4toreprec_3andreprec_4.newnamemust be enclosed in double quotes if it contains spaces. For labeling equations, also seeeqlabels(). Apply optionregexto cause equation specifications to be interpreted as regular expressions. In this case,newnamemay contain\1, ...,\9to reference back to matched subexpressions (and\0for the entire match). For example, typeeqrename(^eq([0-9])0$ = Outcome_\1, regex)to rename equations such aseq20oreq90toOutcome_1orOutcome_9. If the leading^or the tailing$is omitted, only the matched part of an equation name is subject to substitution; the rest of the name will remain unchanged. Include the regular expressions in quotes or compound double quotes if they contain funny characters (such as, e.g., quotes, equal signs, or commas).asequation[(string)] sets the equation name for all included coefficients from the model tostring. This is useful if you want to assign an equation name to results that have been stored without information on equations. Ifasequationis specified without argument, the name of the model is used. If you apply theasequation()option you may also want to specifyeqstrict.swapnamesswaps coefficient names and equation names after collecting the model's results. The names are swapped after applying model options such askeep(),drop(), orrename()but before applying global options such ascoeflabel(),order(), oreqlabels().mlabels(matchlist)specifies marker labels for selected coefficients.matchlistis:coeflist=# "label" [coeflist=# "label" ...] wherecoeflistis as above forkeep()and # is a number 0--12 for the location of the marker label (see[G-4]clockposstyle). Not all of Stata's plot types support marker labels. For example, if you userecast(bar)to change the plot type tobar, no marker labels will be displayed (this has changed with the April 6, 2022, update to Stata 17; plot typebarnow displays marker labels).aux(mspec[mspec...])collects additional results and makes them available as internal variables.mspecis as above forb(). The internal variables are named@aux1,@aux2, ..., and can be used withinif(),weight(),transform(),mlabel(),mlabvposition(), andaddplot()(see Accessing internal temporary variables below). In matrix mode (seePlotting results from matricesbelow), you may also specifyaux(# [# ...])to read the from corresponding rows (or column) of the main matrix. +--------------+ ----+ Plot options +-------------------------------------------------------------label(string)provides a label for the plot to be used in the legend. Use double quotes to create multiline labels. For example,label("This is a" "longlabel")would create a two-line label. For text effects (bold, italics, greek letters, etc.) use SMCL tags as described ingraph_text.key[(ci[#])] determines the key symbol to be used for the plot in the legend.keywithout argument uses the plot's marker symbol; this is the default.key(ci)determines the key symbol from the (first) confidence interval.key(ci #)determines the key symbol from the #th confidence interval; this is only useful if multiple confidence intervals are included in the plot.nokeyprevents including the plot in the legend.pstyle(pstyle)sets the overall style of the plot; see helppstyle.pstyle()affects both, coefficient markers and confidence spikes. To use a different plot style for confidence spikes, addpstyle()withinciopts().axis(#)specifies the scale axis to be used for the plot, where1<#<9. The default is to place all plots on the same scale axis.offset(#)specifies a custom offset for the plot positions. The default is to create automatic offsets to prevent overlap of confidence spikes as soon as there are multiple plots. The spacing between coefficients is one unit, so#should usually be within -0.5 and 0.5.#may also be a scalar expression such as, say,1/6.if(exp)restricts the contents of the plot to coefficients satisfyingexp. The option is useful when you want to select coefficients, e.g., based on their values, plot positions, or confidence limits. Withinexprefer to internal temporary variables as explained in Accessing internal temporary variables below. For example, to include positive coefficients only, you could typeif(@b>=0). Note thatif()does not affect the rendition of the categorical axis (unlessatis specified). That is, a complete categorical axis is created including labels for all collected coefficients, even for the ones that have been removed from the plot byif().weight(exp)scales the size of the markers according to the size of the specified weights (see Weighted markers in helpscatter). Withinexprefer to internal temporary variables as explained in Accessing internal temporary variables below. For example, to scale markers according to the inverse of standard errors, you could typeweight(1/@se).weight()has no effect if marker labels are specified.marker_optionschange the look of the coefficient markers (color, size, etc.); see helpmarker_options.mlabel[(spec)] adds marker labels to the plot. For adding custom labels to specific markers also see model optionmlabels()above. Furthermore, note that not all of Stata's plot types support marker labels. For example, if you userecast(bar)to change the plot type tobar, no marker labels will be displayed (this has changed with the April 6, 2022, update to Stata 17; plot typebarnow displays marker labels). Themlabeloption can be used in three different ways: (1)mlabelwithout argument adds the values of the point estimates as marker labels. Use global optionformat()to set the display format. (2)mlabel(varname)uses the values of the specified variable as marker labels.varnamemay be an internal variable (see Accessing internal temporary variables below). For example,mlabel(@b)is equivalent tomlabelwithout argument. (3)mlabel(strexp)sets the marker labels to the evaluation of the specified string expression. Internal variables can be used withinstrexp(see Accessing internal temporary variables below). For example, you can type mlabel("p = " + string(@pval,"%9.3f")) to display labels such as "p = 0.001" or "p = 0.127". Furthermore, mlabel(cond(@pval<.001, "***", cond(@pval<.01, "**", cond(@pval<.05, "*", "")))) would display significance stars.marker_label_optionschange the look and position of marker labels; see helpmarker_label_options.recast(plottype)plots the coefficients usingplottype; supported plot types arescatter,line,connected,area,bar,spike,dropline, anddot. The defaultplottypeisscatter. The chosen plot type affects the available plot options. For example, if the plot type isbarthenbarlook_optionswill be available. See the plot type's help file for details.cionlycauses markers for point estimates to be suppressed.citopspecifies that confidence intervals be drawn in front of the markers for point estimates; the default is to draw confidence intervals behind the markers.cirecast(plottype)is shorthand notation forciopts(recast()). If both are provided, the plot types specified inciopts(recast())take precedence over the plot types specified incirecast().ciopts(options)affect the rendition of confidence intervals.optionsare:line_optionschange look of spikesrecast(plottype)plot the confidence intervals usingplottypeSupported plot types arerarea,rbar,rspike,rcap,rcapsym,rscatter,rline,rconnected,pcspike,pccapsym,pcarrow(orpcrarrowfor the reverse),pcbarrow, andpcscatter. The defaultplottypeisrspike. The chosen plot type affects the available options withinciopts(). For example, if the plot type isrbarthenbarlook_optionswill be available. See the plot type's help file for details. If multiple confidence intervals are requested, thenstylelistsmay be specified in the options withinciopts(). For example,recast(rspike rcap ..)would userspikefor the first confidence interval andrcapfor the remaining confidence intervals;lwidth(thin medium thick)would use thin lines for the first confidence interval, medium width lines for the second, and thick lines for the third.cismooth[(options)] adds smoothed confidence intervals.optionsare:n(n)number of (equally spaced) confidence levels; default isn(50); levels are placed in steps of 100/nfrom 100/2nto 100-100/2n(e.g., 1, 3, 5, ..., 99 forn=50)lwidth(min max)set range of (relative) line widths; the default isrange(2 15)(maxis exact only forn=50)intensity(min max)set range of color intensities, as percentages; the default isintensity(min100)whereminis determined as 4/(ceil(n/2)+3)*100 (about 14 for n=50)color(color)set the color (without intensity multiplier); the default color is determined by the graph schemepstyle(pstyle)set the overall style; this mainly affects the color The confidence intervals produced bycismoothare placed behind confidence intervals requested inlevels()andci().ciopts()do not apply to them. +------------------+ ----+ Subgraph options +---------------------------------------------------------bylabel(string)provides a label for the subgraph. Use double quotes to create multiline labels. For example,bylabel("This is a" "long label")would create a two-line label. For text effects (bold, italics, greek letters, etc.) use SMCL tags as described ingraph_text. Subgraphs are implemented in terms ofgraph'sby()option; seebyopts()below for options on how to combine and render the subgraphs. +----------------+ ----+ Global options +-----------------------------------------------------------horizontalplaces coefficient values on the x axis. This is the default unlessatis specified.verticalplaces coefficient values on the y axis. This is the default ifatis specified.eqstrictcauses equation names to be taken into account (i.e. match coefficients by equation names and plot equation labels) even if there is only one equation per model.order(coeflist)specifies the order of coefficients (not allowed withat). The default is to use the order as found in the input models (and place_conslast, within equations).coeflistis a space-separated list of elements such as:.insert a gapeq:.insert a gap within equationeqcoefcoefficientcoefeq:all coefficients from equationeq, in their current ordereq:coefcoefficientcoeffrom equationeqwherecoefmay contain "*" (any string) and "?" (any nonzero character) wildcards. If no equations are specified, then the requested order of coefficients is repeated within each equation (keeping the existing order of equations). Otherwise, the requested order is applied across equations. Note that in the later case the first element inorder()must be an equation name.eqis applied to all subsequent elements until a neweqis specified. For example,order(5:weight mpg * 4:turn *)would yield the following order: "weight" from equation "5", "mpg" from equation "5", remaining coefficients from equation "5", "turn" from equation "4", remaining coefficients from equation "4", remaining equations if any.orderby([subgraph:][plot])orders the coefficients by a specific model. By default, the coefficients are ordered according to how they are provided tocoefplot, with earlier plots and subgraphs taking precedence over later ones (and placing_conslast). This means that coefficients that only appear in later models will be placed after the coefficients that appear in earlier models. Specify theorderby()option if you want to change the default behavior and arrange the coefficients according to their order in a specific model (and, within each equation, place the other coefficients after these coefficients, but before_cons). Argumentssubgraphandplotselect the relevant model. For example,orderby(2:3)will order coefficients according to the model that is displayed in the third plot of the second subgraph. If one of the arguments is omitted, it defaults to one. Hence,orderby(3)will order the coefficients according to the model displayed in the third plot of the first subgraph;orderby(2:)will use the model displayed in the first plot of the second subgraph.orderby()will do nothing if a specified subgraph or plot does not exist. Furthermore, note that thesubgraphargument is not allowed if thenorecycleoption has been specified; plots are numbered uniquely across subgraphs in this case.sort[(spec)] sorts the coefficients by size.specis [subgraph:][plot] [,descendingby(stat)] wheresubgraphandplot, being equal to.or a positive integer, identify the subgraph and plot to be used to establish the sort order. For example, to sort based on all values in the second subgraph (possibly including multiple plots), typesort(2:)orsort(2:.); to sort based on all values in the third plot (possibly spanning multiple subgraphs), typesort(3)orsort(.:3); to sort based on the values of the third plot in the second subgraph, typesort(2:3). Specifyingsortwithout argument is equivalent tosort(.:.), that is, to sort based on the values in all available subgraphs and plots. If you specify a subgraph or plot that does not exist,sort()will do nothing. Furthermore, if thenorecycleoption is specified, thesubgraphargument can be omitted as the plots will be uniquely numbered across subgraphs. By default, the coefficients are sorted in ascending order of the values of the point estimates. Specify suboptiondescendingto use a descending sort order. Furthermore, useby(stat)to change the relevant statistic, wherestatmay be:bsort by point estimate (the default)v(orse) sort by variance (or standard error)tsort by t (or z) statistictabssort by absolute t (or z) statisticpsort by p-valuedfsort by degrees of freedomll[#] sort by (#th) lower confidence limit; # defaults to 1ul[#] sort by (#th) upper confidence limit; # defaults to 1aux[#] sort by (#th) auxiliary variable (see theaux()option); # defaults to 1 In case of multiple equations, coefficients will be sorted separately within each equation, keeping the original order of equations. Use theorder()option the change the order of the equations.relocate(spec)assigns specific positions to the coefficients on the category axis.specis: [eq:]coef=# [[eq:]coef=# ...] whereeqandcoefmay contain "*" (any string) and "?" (any nonzero character) wildcards. Ifbycoefsis specified, use numbers (1, 2, ...) instead ofeqandcoefto address the elements on the categorical axis. The default forcoefplotis to place coefficients at integer values 1, 2, 3, ... (from top to bottom in horizontal mode, from left to right in vertical mode). Therelocate()option gives you the possibility to specify alternative values. If, for example, you want to place coefficientmpgat value 2.5 on the category axis, you could typerelocate(mpg = 2.5). If you only want to change the order of coefficients and are fine with integer positions, then use theorder()option. Note that the specified positions are assigned before inserting gaps between equations, headings, and groups (seeeqlabels(),headings(), andgroups()). Hence, the final plot positions might deviate from the specified positions if there are equation labels, headings, or group labels.bycoefsflips subgraphs and coefficients (not allowed withat). Ifbycoefsis specified, a separate subgraph is produced for each coefficient. In this case, use integer numbers (1, 2, ...) instead of coefficient names to address the elements on the categorical axis within optionsrelocate(),headings(), andgroups().norecycleincrements plot styles across subgraphs. The default is to start over with each new subgraph.nooffsetssuppresses automatic offsets for plot positions.format(format)sets the display format for coefficients. This affects the rendition of the axis and marker labels.formatmay be a numeric format or a date format (see helpformat).p#(plotopts)specifies options for the#th plot. For example, typep2(nokey)to exclude plot 2 from the legend (seenokey). Use thep#()options as an alternative to specifying options directly within a plot; in case of conflict, options specified within a plot take precedence over options specified viap#().nolabelscauses coefficient names to be used as labels instead of variable labels or value labels.coeflabels(spec)specifies custom labels for coefficients (not allowed withat).specis [coeflist="label"[coeflist="label"...]] [,truncate(#)wrap(#)nobreakinteraction(string)suboptions] withcoeflistas above forkeep(). Encloselabelin double quotes if it contains spaces, e.g.coeflabels(foreign = "Car Type"). Encloselabelin compound double quotes to create a multiline label, e.g.coeflabels(foreign = `""This is a" "long label""'); alternatively, apply thewrap()option. For text effects (bold, italics, greek letters, etc.) use SMCL tags as described ingraph_text. Optiontruncate(#)truncates coefficient labels to a maximum length of # characters. Optionwrap(#)divides coefficient labels into multiple lines, where each line has a maximum length of # characters.truncate()andwrap()operate on words. That is, they try to fill to the maximum length without breaking in the middle of a word. However, if a word is longer than # characters, it will be split or truncated. Specifynobreakto preventtruncate()andwrap()from splitting or truncating words that are longer than # characters. Iftruncate()andwrap()are both specified,truncate()is applied first.interaction()specifies the string to be used as delimiter in labels for interaction terms; the default isinteraction(" # ").suboptionsare axis label suboptions as described inaxis_label_options. Note: Labels containing multiple lines are left unchanged bytruncate()andwrap(). Therefore, if you don't like howwrap()breaks a specific label, you can provide a custom variant of it incoeflabels()while still usingwrap()for the other labels.truncate()andwrap()may fail to process a label if it contains compound double quotes; the label will be left unchanged in this case.noeqlabelssuppresses equation labels.eqlabels(spec)specifies custom labels for equations, one after the other (not allowed withat).specis: ["label"["label"...]] [,labels[(string)] []nogap[(#)]asheadingsoffset(#)truncate(#)wrap(#)nobreaksuboptions] Enclose labels in double quotes if they contain spaces, e.g.eqlabels("EQ one" "EQ two"). Enclose labels in compound double quotes to create multiline labels, e.g.eqlabels(`""This is a" "long label""'). Alternatively, apply thewrap()option. For text effects (bold, italics, greek letters, etc.) use SMCL tags as described ingraph_text. Optionlabelcauses the equation names to be treated as variable names;coefplotwill then use the corresponding variable labels (and, depending on context, value labels) to label the equations. Specifylabel(string)to set the string to be used as delimiter in labels for interaction terms; typinglabelwithout argument is equivalent tolabel(" # ").gap()specifies the size of the gap between equations. The default isgap(1).nogapsuppresses the gap between equations.asheadingstreats equation labels as headings; seeheadings().offset(), only allowed withasheadings, offsets the labels.truncate(),wrap(),nobreak, andsuboptionsare as above forcoeflabels().headings(spec)adds headings between coefficients (not allowed withat).specis:coeflist="label"[coeflist="label"...] [,[]nogap[(#)]offset(#)truncate(#)wrap(#)nobreaksuboptions] withcoeflistas above forkeep(). Ifbycoefsis specified, use numbers 1, 2, ... instead ofcoeflistto address the elements on the categorical axis. Encloselabelin double quotes if it contains spaces. For example,headings(0.foreign = "Car Type")will print the heading "Car Type" before coefficient "0.foreign". Encloselabelin compound double quotes to create a multiline label, e.g.headings(foreign = `""This is a" "long heading""'). Alternatively, apply thewrap()option. For text effects (bold, italics, greek letters, etc.) use SMCL tags as described ingraph_text.gap()andoffset()are as above foreqlabels().truncate(),wrap(),nobreak, andsuboptionsare as above forcoeflabels().groups(spec)adds labels for groups of coefficients (not allowed withat). The specified label will be printed beside (or, in vertical mode, below) the identified group of coefficients.specis:coeflist="label"[coeflist="label"...] [,[]nogap[(#)]truncate(#)wrap(#)nobreaksuboptions] withcoeflistas above forkeep(). Ifbycoefsis specified, use numbers 1, 2, ... instead ofcoeflistto address the elements on the categorical axis. Encloselabelin double quotes if it contains spaces. Encloselabelin compound double quotes to create a multiline label. Alternatively, apply thewrap()option. For text effects (bold, italics, greek letters, etc.) use SMCL tags as described ingraph_text.gap()is as above foreqlabels().truncate(),wrap(),nobreak, andsuboptionsare as above forcoeflabels().plotlabels(spec)specifies labels for the plots to be used in the legend. Labels specified viaplotlabels()take precedence over labels specified in thelabel()plot option.specis: ["label"["label"...]] [,truncate(#)wrap(#)nobreak] Enclose labels in double quotes if they contain spaces. Enclose labels in compound double quotes to create multiline labels. Alternatively, apply thewrap()option. For text effects (bold, italics, greek letters, etc.) use SMCL tags as described ingraph_text. Optionstruncate(),wrap(), andnobreakare as above forcoeflabels().bylabels(spec)specifies labels for the subgraphs. Labels specified viabylabels()take precedence over labels specified in thebylabel()subgraph option.specis: ["label"["label"...]] [,truncate(#)wrap(#)nobreak] Enclose labels in double quotes if they contain spaces. Enclose labels in compound double quotes to create multiline labels. Alternatively, apply thewrap()option. For text effects (bold, italics, greek letters, etc.) use SMCL tags as described ingraph_text. Optionstruncate(),wrap(), andnobreakare as above forcoeflabels().grid(options)affects the rendition of grid lines on the category axis (not allowed withat).optionsare: {between|within|none}suboptionsbetweenplaces grid lines between coefficient labels;withinplaces grid lines at the center of coefficient labels;nonesuppress grid lines.suboptionsare axis label suboptions as described inaxis_label_options. In horizontal mode, the default iswithinfor single plots andbetweenfor multiple plots. In vertical mode, the default isnone. Alternatively, useytick()andxtick()to set grid lines.generate[(prefix)] generates variables containing the graph data. The variable names will be prefixed by "__" or as specified byprefix.replaceallowscoefplotto overwrite existing variables.addplot(plot)adds other plots to the graph. See helpaddplot_option. By defaultaddplot()has access only to the firstrobservations in the dataset, whereris the number of observations used bycoefplotto store its internal results. If the graph does not contain multiple subgraphs andgenerate()ornodropis specified,addplot()has access to all observations.nodropcausescoefplotto keep all observations when generating the graph. The default is to eliminate unused observations temporarily to increase speed.nodropmay be useful in connection with theaddplot()option, if the graph does not contain multiple subgraphs.nodrophas no effect ifgenerate()is specified.twoway_optionsare general twoway options, other thanby(), as documented in helptwoway_options.byopts(byopts)determines how subgraphs are combined.byoptsare as described in helpby_option.. sysuse auto . regress price mpg headroom trunk length turn . coefplot, drop(_cons) xline(0) . regress price mpg headroom trunk length turn if foreign==0 . estimates store domestic . regress price mpg headroom trunk length turn if foreign==1 . estimates store foreign . coefplot domestic foreign, drop(_cons) xline(0) . coefplot domestic || foreign, drop(_cons) xline(0) . coefplot domestic || foreign, yline(0) bycoefs vertical byopts(yrescale) For further examples see the website, the Stata Journal article, or the working paper.ExamplesRemarks are presented under the following headings: Using wildcards in model names Placement of options Plotting results from matrices Accessing internal temporary variablesRemarksInstead of providing distinct model names toUsing wildcards in model namescoefplot, you can also specify a name pattern containing*(any string) and?(any nonzero character) wildcards.coefplotwill then plot the results from all matching models. If a name pattern is specified as part of a plot delimited by parentheses, the results from the matching models will be combined into the same plot. For example, if modelsest11,est12,est13,est21,est22, andest23are in memory, typing. coefplot (est1*,opts1) (est2*,opts2)is equivalent to. coefplot (est11 est12 est13,opts1) (est21 est22 est23,opts2)Likewise, typing. coefplot (est*1,opts1\ est*2,opts2\,opts3)is equivalent to. coefplot (est11 est21,opts1\ est12 est22,opts2\,opts3)If a name pattern is specified without parentheses, the matching models are treated as separate plots. For example, typing. coefplot est1* || est2*is equivalent to. coefplot est11 est12 est13 || est21 est22 est23or. coefplot (est11) (est12) (est13) || (est21) (est22) (est23)Use global optionsp1(),p2(), etc. to provide specific options to the different plots in this case. For example, typing. coefplot est1*, p1(opts1) p2(opts2) p3(opts3)is equivalent to. coefplot (est11,opts1) (est12,opts2) (est13,opts3)Placement of optionscoefplothas four levels of options: (1)modeloptsare options that apply to a single model (or matrix). They specify the information to be displayed. (2)plotoptsare options that apply to a single plot, possibly containing results from multiple models. They affect the rendition of markers and confidence intervals and provide a label for the plot. (3)subgroptsare options that apply to a single subgraph, possibly containing multiple plots. (4)globaloptsare options that apply to the overall graph. The levels are nested in the sense that upper level options include all lower level options. That is,globaloptsincludessubgropts,plotopts, andmodelopts;subgroptsincludesplotopts, andmodelopts;plotoptsincludesmodelopts. However, upper level options may not be specified at a lower level. If lower level options are specified at an upper level, they serve as defaults for all included lower levels elements. For example, if you want to draw 99% and 95% confidence intervals for all included models, specifylevels(99 95)as global option:. coefplot model1 model2 model3, levels(99 95)Options specified with an individual element override the defaults set by upper level options. For example, if you want to draw 99% and 95% confidence intervals for model 1 and model 2 and 90% confidence intervals for model 3, you could type:. coefplot model1 model2 (model3, level(90)), levels(99 95)There are some fine distinctions about the placement of options and how they are interpreted. For example, if you type. coefplot m1,opts1|| m2,opts2opts3thenopts2andopts3are interpreted as global options. If you want to applyopts2only tom2then type. coefplot m1,opts1|| m2,opts2||,opts3Similarly, if you type. coefplot (m1,opts1\ m2,opts2)thenopts2will be applied to both models. To applyopts2only tom2type. coefplot (m1,opts1\ m2,opts2\)or, if you also want to includeopts3to be applied to both models, type. coefplot (m1,opts1\ m2,opts2\,opts3)or. coefplot (m1,opts1\ m2,opts2\),opts3In case of multiple subgraphs there is some ambiguity about where to specify the plot options (unless global optionnorecycleis specified). You can provide plot options within any of the subgraphs as plot options are collected across subgraphs. However, in case of conflict, the plot options from the rightmost subgraph usually take precedence over earlier plot options. In addition, you can also use global optionsp1(),p2(), etc. to provide options for specific plots. In case of conflict, options specified within a plot take precedence over options provided viap1(),p2(), etc.Use syntaxPlotting results from matricesmatrix(mspec)instead of the name of a stored model to plot results from a matrix.mspecmay be:nameuse first row of matrixnamename[#,.]use #th row of matrixname; may also typename[#,]orname[#]name[.,#]use #th column of matrixname; may also typename[,#]If thematrix()syntax is used, then optionb()is discarded and names given inat(),ci(),v(),se(),df(), andaux()refer to regular matrices instead ofe()-matrices. The matrix name may be omitted in these options if results are to be read from the same matrix; only the relevant row or column numbers have to be provided in this case (whether the numbers are interpreted as row or column numbers depends in howmatrix()was specified). For example, to plot medians and their confidence intervals as computed bycentileyou could type:sysuse auto, clearmatrix C = J(3,3,.)matrix rownames C = median ll95 ul95matrix colnames C = mpg trunk turnlocal i 0foreach v of var mpg trunk turn {local ++ icentile `v'matrix C[1,`i'] = r(c_1) \ r(lb_1) \ r(ub_1)}matrix list Ccoefplot matrix(C), ci((2 3))This is equivalent to:coefplot matrix(C[1]), ci((C[2] C[3]))Note that a singlecoefplotcommand can contain both regular syntax andmatrix()syntax. For example, to add means to the graph above you could type:mean mpg trunk turnestimates store meancoefplot (matrix(C), ci((2 3))) (mean)Accessing internal temporary variablescoefplotmaintains a number of internal variables that can be used withinif(),weight(),transform(),mlabel(),mlabvposition(), andaddplot(). These variables are:@bpoint estimates@ll# lower limits of confidence interval # (may use@llfor@ll1)@ul# upper limits of confidence interval # (may use@ulfor@ul1)@Vvariances@sestandard errors@tt or z statistics, computed as @b/@se@dfdegrees of freedom@pvalp-values, computed as (1-normal(|@t|))*2 or ttail(@df,|@t|)*2, depending on whether df are available@atplot positions@plotplot ID (labeled)@bysubgraph ID (labeled)@mlblMarker labels set bymlabels()(string variable)@mlposMarker label positions set bymlabels()@aux# auxiliary variables collected byaux()(may use@auxfor@aux1) The internal variables can be used like other variables in the dataset. For example, optionmlabel(@plot)would add plot labels as marker labels or optionaddplot(line @at @b)would draw a connecting line through all point estimates in the graph.Saved resultscoefplotreturns the following macros and scalars inr(): Scalarsr(n_ci)number of confidence intervalsr(n_plot)number of plotsr(n_subgr)number of subgraphs Macrosr(graph)copy of graph commandr(labels)coefficient labelsr(eqlabels)equation labelsr(groups)group labelsr(headings)headingsr(legend)contents of legend optionBen Jann, University of Bern, ben.jann@unibe.ch Thanks for citing this software in one of the following ways: Jann, B. (2014). Plotting regression coefficients and other estimates. The Stata Journal 14(4): 708-737. Jann, B. (2013). Plotting regression coefficients and other estimates in Stata. University of Bern Social Sciences Working Papers Nr. 1. Available from http://ideas.repec.org/p/bss/wpaper/1.html. Jann, B. (2013). coefplot: Stata module to plot regression coefficients and other results. Available from http://ideas.repec.org/c/boc/bocode/s457686.html.Author