Title
Plots the estimates from a series of lincom commands
Syntax
plotbeta exp [, options]
options Description ------------------------------------------------------------------------- Main position(numlist) specifies the position of the confidence intervals. eform specifies that the exponentiated form the parameters be plotted. vertical specifies that the confidence intervals are plotted vertically. level(#) specifies the confidence level. labels specifies that variable labels are used in the plot. savedata(filename) specifies that the data in the final plot should be saved. addplot(graph) specifies that an additional twoway graph is added to the plot. twoway_options -------------------------------------------------------------------------
where exp is defined
lincom_exp [|]
and where lincom_exp may be any linear combination of coefficients that is valid syntax for test. Note, however, that exp may not contain an equal sign.
Description
This command will plot the parameter estimates and confidence intervals from a series of lincom commands.
Updating this command using SSC
To obtain the latest version click the following to install the new version
ssc install plotbeta,replace
Options
position(numlist) specifies the position of the confidence intervals. The default is that the point estimate and confidence intervals are plotted at points 1 2 3 ... It is possible to group confidence intervals in different parts of the plots e.g. 1 2 3 3.1 3.2, here the last three confidence intervals will be much closer to each other.
eform specifies that the exponentiated form the parameters be plotted.
labels specifies that if the lincom expression is a variable then that variable's label is used instead of the variable name. This option is particularly useful if the linear predictor is made up entirely of main effects.
vertical specifies that the confidence intervals are plotted vertically rather than the default of horizontally.
level(#) specifies the confidence level, in percent, for confidence intervals; see level.
savedata(filename) specifies that the data in the final plot should be saved.
addplot(graph) specifies that an additional twoway graph is added to the plot. This is particularly useful for adding additional datapoints using twoway_scatteri.
Examples
A linear regression using the auto data, click the highlighted text in order
sysuse auto, clear reg price mpg turn length plotbeta mpg | turn | length plotbeta mpg | turn | length, labels plotbeta mpg | turn | length, addplot((scatteri 2.5 2.5, ms(S) msize(*2))) la > bels
To remove the green text on the right hand side of the plot you need to add in the following two options
plotbeta mpg | turn | length, addplot((scatteri 2.5 2.5, ms(S) msize(*2))) labels ylab(none, axis(2)) ytitle("", axis(2))
This is the most basic graphic and using twoway options the look can be improved. The following command puts the confidence intervals
plotbeta mpg | turn | length | mpg-length , xtitle(Parameters) yscale(range(0.7 4.3) axis(1)) yscale(range(0.7 4.3) axis(2)) title(Coefficients and Confidence Intervals) subtitle(from a Simple Linear Regression) xline(0, lp(dash))
An example using Survival data, click the highlighted text in order
sysuse cancer stset studytime, f(died) xi:stcox i.drug age plotbeta _Idrug_2 | _Idrug_3 plotbeta _Idrug_2 | _Idrug_3, labels eform savedata(temp,replace)
Using the twoway options to solve a problem with labelling
plotbeta age | _Idrug_2 | _Idrug_3, eform labels xline(1, lp(dash))
Note that by adding age into the estimates the ylabels are off the graph. This is due to the single quote in the variable label. Either change the label or alter the graphregion size
plotbeta age | _Idrug_2 | _Idrug_3, eform labels xline(1, lp(dash)) graphregion(margin(l+40 r+15))
Author
Adrian Mander, MRC Biostatistics Unit, Cambridge, UK.
Email adrian.mander@mrc-bsu.cam.ac.uk
Also see
Related commands
HELP FILES lincom