1

I would like to draw a confidence ellipse (sometimes also called concentration ellipse) for two continuous variables using Stata.

There is a community-contributed command called ellip for this kind of graph, a detailed description of which is provided by its author Anders Alexandersson on Stata Journal. However, I would like to apply weights for the ellipse which is not possible using this command.

Below is a reproducible example where I try to plot the number of marriages per 1000 inhabitants over the percentage of urban population in US states using the population size as a weight:

clear all
sysuse census

gen marpop = marriage / pop * 1000
gen urbpop = popurban / pop * 100

ellip marpop urbpop if state2!="NV", plot(scatter marpop urbpop if state2!="NV") ///
    name(ellip_noaw)
ellip marpop urbpop if state2!="NV", plot(scatter marpop urbpop [aw=pop] if state2!="NV") ///
    name(ellip_aw)

graph combine ellip_noaw ellip_aw

The results look as follows:

Confidence ellipse example

As you can see the second ellipse, where the points of the scatter plot are weighted/inflated by the population size, should be possibly shifted to the bottom-right.

How can I create a weighted confidence ellipse in Stata?

  • 2
    You will need to write your own program for that or alter the source code of `ellip`. –  Jun 08 '19 at 21:10
  • Yes, @PearlySpencer I probably have to rewrite parts of `ellip`. But I am not sure where to start as I do not know whether the formula used by Alexandersson (2004: 253-254) holds for weighted data. If @anders-alexandersson is the author of the ado, he might have an idea how to proceed? – non-numeric_argument Jun 09 '19 at 15:37
  • I think writing to the author of the command is your best bet. Your question on here is unlikely to get an answer as would require a lot of effort for someone and non-programming expertise in this area to come up with the solution. –  Jun 10 '19 at 12:08

0 Answers0