Transcription of A new command for plotting regression coefficients and ...
1 A new command for plotting regression coefficientsand other estimatesBen JannUniversity of Bern, German Stata Users Group meetingHamburg, June 13, 2014 Ben Jann (University of Bern) plotting EstimatesHamburg, coefplot commandIBasic usageILabelsIConfidence intervalsIThe recast optionIMarker labelsIThe at optionBen Jann (University of Bern) plotting EstimatesHamburg, estimates such as coefficients from regression models areoften presented as tables in research articles and , results display in form of graphs can me much moreeffective than tabulation. This is because the .. reexpression of data in pictorial form capitalizes upon one of themost highly developed human information processing capabilities theability to recognize, classify, and remember visual patterns. (Lewandowsky and Spence 1989:200)Graphs do a great job in revealing patterns, trends, and relativequantities (Jacoby 1997:7) because they translate differencesamong numbers into spacial distances, thereby emphasizing the mainfeatures of the , pictorial representations seem to be easier to remember thantabular results (Lewandowsky and Spence 1989).
2 Ben Jann (University of Bern) plotting EstimatesHamburg, at Bibliothek Sozialwissenschaft on May 12, from (Lewandowsky and Spence 1989:209)Ben Jann (University of Bern) plotting EstimatesHamburg, many applications, statistics is about estimation based on sampledata. Since estimation results are uncertain, standard errors,statistical tests, or confidence intervals are of results should reflect precision or uncertainty. Thisis why so called ropeladder plots have become increasinglypopular. They display, against a common scale,Imarkers for point estimates ( of regression coefficients )Iand spikes or bars for confidence intervals ( error bars ).Ropeladder plots are effective because they capitalize on two of themost powerful perceptional capabilities of humans evaluating theposition of points along a common scale and judging the length oflines (Cleveland and McGill 1985).
3 Furthermore, they provide amuch better impression of statistical precision than p-values orsignificance stars in Jann (University of Bern) plotting EstimatesHamburg, s an early exampleof an error-bar plot in apaper by Student (1927)(Thanks to Nick Cox for pointing me tothis and some of the following examples.)158 Errors of Routine Analysis To embark on a long series of analyses in order to determine error is always a considerable undertaking and is often impossible owing to the tendency of organic substances to change with time: added to this, unless special precautions are taken, such as were taken in 1905, the operators may, in spite of themselves, be more carefiul when analysing special samples of this kind, so that the series may not represent a random sample of analytical errors. 20'0 16-0 -15 0 31 2 4 6 8 1012141618202224262830 2 4 6 8 101214161820 1 3 5 7 9 11131517 192123252729 1 3 5 7 9 1113 15171921 OCTOBER NOVEMBER DECEMBER Fig.
4 3. Means of Daily Analyses with lines showing on each side of the Mean twice the appropriate to the Number of Analyses made on any given day. The is derived from the total observations by the formula a^n' s/ S(I-1) where a = Average .of a Farm, a =-Mean of a Day's Analyses, n=Number of Farms analysed in the Day. It is convenient, therefore, to take advantage of the fact that important anialyses are often repeated as part of the rouitine and to calcuilate the Standard Deviation of the error from the differences between pairs by simply dividing the variance of the differences by 2 and taking the square root. This content downloaded from on Tue, 27 May 2014 12:02:38 PMAll use subject to JSTOR Terms and ConditionsBen Jann (University of Bern) plotting EstimatesHamburg, (Dice and Leraas 1936)Ben Jann (University of Bern) plotting EstimatesHamburg, (Cleveland 1994)Ben Jann (University of Bern) plotting EstimatesHamburg, (Harrell 2001)Ben Jann (University of Bern) plotting EstimatesHamburg, (Harrell 2001)Ben Jann (University of Bern) plotting EstimatesHamburg, row, given the portrait orientation of journals.
5 Thex-axis depicts which model is being displayed. To facilitatecomparison across predictors, we center the y-axis at zero,which is the null hypothesis for each of the regression table presents six models, which varywith respect to sample (full sample vs. excluding partisansregistration counties) and predictors (with/without stateyear dummies and with/without law change). On the x-axiswe group each type of model: full sample, excludingcounties with partial registration and full sample withstate year dummies. Within each of these types, two dif-ferent regressions are presented: including the dummy vari-ablelaw changeand not including it. Thus, for each type,we plot two point estimates and intervals we differenti-ate the two models by using solid circles for the models inwhichlaw changeis included and empty circles for themodels in which it is not.
6 We again choose not to graphthe estimates for the constants because they are not sub-stantively graphing strategy allows us to easily compare pointestimates and confidence intervals across models. Althoughin all the specified models thepercent of county with regis-trationpredictor is statistically significant at the 95 per-cent level, it is clear from the graph that estimates fromthe full sample with state/year dummies models are sig-nificantly different from the other four models. In addi-tion, by putting zero at the center of the graph, it becomesobvious which estimates have opposite signs depend-ing on the specification (log populationandlog medianfamily income). By contrast, it is much more difficult tospot these changes in signs in the original table. Thus, byusing a graph it is easy to visually assess the robustness ofeach predictor both in terms of its magnitude and con-fidence interval simply by scanning across each summary, the graph appropriately highlights the insta-bility in the estimates depending on the choice of 8 Pekkanen, Nyblade and Krauss (2006),table 1: Logit analysis of electoralincentives and LDP post allocation(1996 2003)VariableModel 1 Model 2 Block 1: MP (.)
7 22) ( )SMD Only ( ) ( )PR Only ( )** Costa Rican in PR ( ) Block 2: Electoral StrengthVote share margin ( )Margin Squared Block 3: Misc ControlsUrban-Rural ( ) ( )No FactionalMembership ( )** ( )**Legal ( ) .36 ( )Seniority1stTerm ( )** ( )**2ndTerm ( )** ( )**4thTerm ( )** ( )**5thTerm ( )** ( )**6thTerm ( )** ( )**7thTerm ( )** ( )**8thTerm ( )** ( )**9thTerm ( )** ( )**10thTerm ( )** ( )**11thTerm ( )** ( )**12thTerm ( )** ( )** (.20) ( )Log-likelihood :Dependent Variables: 1 if MP holds a post of minister,vice minister, PARC, or HoR Committee categories: SMD dual-listed, 3rd term. Excluded obser-vations: senior MPs that held no post (> 12 terms, PR-OnlyMPs in Model 2).*p < .10, **p < .05, **p < . 7 Using parallel dot plots with error bars topresent two regression 1 from Pekkanen et al.
8 2006 displays two logistic regres-sion models that examine the allocation of posts in the LDP partyin Japan. We turn the table into a graph, and present the two mod-els by plotting parallel lines for each of them grouped by coef-ficients. We differentiate the models by plotting different symbolsfor the point estimates: filled (black) circles for Model 1 andempty (white) circles for Model 2.||!!!December 2007|Vol. 5/No. 4767(Kastellec and Leoni 2007)Ben Jann (University of Bern) plotting EstimatesHamburg, graphs of point estimates and confidence intervals has beennotoriously difficult in Stata (although see Newson 2003).1. gather coefficients and variances from thee()-returns2. compute confidence intervals3. store results as variables4. create a variable for the category axis5. compile labels for coefficients6.
9 Run a lengthy graph commandThings got better with the introduction ofmarginsplotin Stata12. Withmarginsplotit is easily possible to create a ropeladderplot from results left behind Jann (University of Bern) plotting EstimatesHamburg, sysuse auto, clear(1978 Automobile Data). regress price mpg trunk length turnSourceSS df MS Number of obs = 74F( 4, 69) = 4 Prob F = 69 R-squared = R-squared = 73 Root MSE = Std. Err. t P t [95% Conf. Interval] Jann (University of Bern) plotting EstimatesHamburg, margins, dydx(*) postAverage marginal effects Number of obs = 74 Model VCE : OLSE xpression : Linear prediction, predict()dy/dx : mpg trunk length turnDelta-methoddy/dx Std.
10 Err. t P t [95% Conf. Interval] Jann (University of Bern) plotting EstimatesHamburg, marginsplot, horizontal xline(0) yscale(reverse) recast(scatter)Variables that uniquely identify margins: derivmpgtrunklengthturnEffects with Respect to-600-400-2000200 Effects on Linear PredictionAverage Marginal Effects with 95% CIsBen Jann (University of Bern) plotting EstimatesHamburg, coefplot commandmarginsplotis a very versatile command that can do much morethan what is shown above, especially when plotting ,marginsplotcan only deal with results left behind bymarginsand also has various other therefore wrote a new command calledcoefplot. It is a generaltool to graph results from estimation commands in Stata, similar tooutreg(Gallup 2012) orestout(Jann 2007) for Jann (University of Bern) plotting EstimatesHamburg, coefplot commandSome ofcoefplot s functionality overlaps with the possibilitiesoffered bymarginsplot, butcoefplotgoes much beyond.