Virata manual

coefplot

Draws the coefficients of the model you just fitted, with their error bars.

What we have

  • the coefficients of the last regress, logit, probit, poisson or nbreg
  • 95% intervals, constant, keep() and drop()

Coming later

  • plotting two models side by side
  • a margins plot, since margins itself is not built

How you write it

coefplot [, constant] [keep(terms)] [drop(terms)]

Square brackets mean optional. A vertical bar means choose one.

What it does

A table of twenty coefficients is hard to read; the same twenty as points with 95% intervals, against a line at zero, takes a second. Anything whose interval crosses zero is not distinguishable from no effect.

It reads the last regress, logit, probit, poisson or nbreg, so run it straight afterwards. The constant is left out unless you ask, and keep() or drop() let you exclude coefficients measured on wildly different scales, which would otherwise squash the rest flat.

Try it

Every example below was run after sysuse vira.sample02, clear.

. regress mpce age education
Linear regression                            Number of obs      =        6,000
                                             F statistic        =       277.09
                                             Prob > F           =       0.0000
                                             R-squared          =       0.0846
                                             Root MSE           =     1420.652

------------------------------------------------------------------------------
        mpce | Coefficient  Std. err.      t   P>|t|     [95% conf. interval]
-------------+----------------------------------------------------------------
         age |    6.137629   .9780934    6.28   0.000     4.220214    8.055044
   education |    91.08834   3.980503   22.88   0.000     83.28513    98.89156
       _cons |    2743.849   58.66231   46.77   0.000     2628.849    2858.848
------------------------------------------------------------------------------
The same thing in pandas and in R

pandas

import statsmodels.formula.api as smf
model = smf.ols("mpce ~ age + education", data=df).fit()

R

model <- lm(mpce ~ age + education, data = df)
summary(model)

# This R was run in a real R (4.6.1) and gave the same numbers.
. coefplot
(graph saved to graph_coefplot.html)
The same thing in pandas and in R

pandas

# rendered with D3; see graph_coefplot.html

R

# no R form for `coefplot` yet -- see docs/r-equivalents.md

Nearby

regress logit probit poisson nbreg ologit