Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • One weird trick for speeding up coefplot on large data sets

    Ben Jann's super-useful coefplot generates temporary variables in order to make its plots. And it leaves those variables behind if you use the generate option. I've found that in large data sets this causes a severe speed penalty. The temporary variables are filled mostly with missing, because the data set is much taller than coefplot needs for its variables.

    I found an elegant fix for Stata versions that support frames:

    Code:
    cap frame create cp  // one-time setup
    
    sysuse auto
    reg price mpg
    frame cp: coefplot
    Example with the generate option:
    Code:
    frame cp: coefplot, gen replace
    frame cp: `r(graph)' title(Great graph)
    In older Stata I would sometimes do
    Code:
    preserve
    keep in 1
    coefplot
    restore
    But using a frame should be faster.

  • #2
    Many thanks for pointing this out, David. I fixed the problem in the latest update (ssc install coefplot, replace); there is no longer a performance loss in large datasets. ben

    Comment

    Working...
    X