Having a clustered dataset, I want to visualize a scatter plot for two fields so every cluster is shown on the plane by its mean value (also good to have a radius equal to std). How does one do this in Stata?

  • 1
    $\begingroup$ If you have (x,y) points, which std do you want to use? $\endgroup$
    – dimitriy
    Commented Oct 16, 2014 at 17:57
  • $\begingroup$ Are you simply asking for Stat code? $\endgroup$ Commented Oct 16, 2014 at 18:45

1 Answer 1


Here's an example with the auto data that uses two rings whose areas are proportional to standard deviations, which is not quite what your want, but is fairly easy:

sysuse auto, clear
collapse (mean) price mpg (sd) sd_price = price sd_mpg = mpg, by(rep78)

tw (scatter price mpg [w=sd_price], ms(Oh)) (scatter price mpg [w=sd_mpg], ms(Oh)) (scatter price mpg, msymbol(none) mlabpos(0) mlabel(rep78)), legend(off)


The missing group corresponds to "."

This way of plotting the data does not seems like a good idea, as it obscures some features of the data. For instance, you get the sense that SD of price is larger than SD of MPG, but for group 1, the former is 200 times the latter, though the bubbles appear the same size.

  • $\begingroup$ May be you are right regarding the plot representation. The key new thing there is the collapse command. It saved my day $\endgroup$ Commented Oct 16, 2014 at 19:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.