Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: st: 2 dimensional graph for joint distribution


From   Nick Cox <njcoxstata@gmail.com>
To   "statalist@hsphsun2.harvard.edu" <statalist@hsphsun2.harvard.edu>
Subject   Re: st: 2 dimensional graph for joint distribution
Date   Wed, 30 Oct 2013 12:52:55 +0000

The graph in question is a two-dimensional distribution shown as a
perspective view of a three-dimensional column chart on a inclined
plane.

I regard this as a graphical horror, not least because some columns
are occluded. Be aware that many writers on statistical graphics warn
against using such plots. The main objection is that the third
dimension is spurious and doesn't actually help in getting an overview
of the data. For example, it can be hard to know exactly how to read
across from column tops to the vertical axis.

Nevertheless, this counts as a standard graph in some other software.

I don't think it is supported in Stata, any way.

Among various alternatives are

1. A scatter plot.

2. A two-way bar chart, as supported by -tabplot- (SSC). Here's a
dopey example of how to bin and plot the joint distribution of two
continuous variables.

sysuse auto, clear
clonevar length2 = length
replace length2 = 25 * floor(length/25)
clonevar weight2 = weight
replace weight2 = 500 * floor(weight/500)
tabplot weight2 length2, showval ysc(reverse)

The main point of -clonevar- here is to copy any variable labels,
which will show up on the graph.

The -floor()- function is used here to get equal-width bins defined by
their lower limits.


Nick
njcoxstata@gmail.com


On 30 October 2013 11:07, Lulu Zeng <luluzengnz@gmail.com> wrote:
> Dear Statalist
>
> I am having trouble creating a two dimensional joint distribution bar
> graph in Stata.
>
> I'm trying to graph the joint distribution of 2 coefficients I
> estimated from a nonparametric choice model using fixed mass point
> method following Kenneth Train's approach in his 2008 paper (EM
> Algorithms for nonparametric estimation of mixing distributions). The
> graph I am trying to make is similar to the one on page 65 of Train's
> paper: http://elsa.berkeley.edu/~train/EMtrain.pdf
>
> My 2 coefficients (both discrete) are called odo and bill, and the
> variable share gives the distribution of the 2 coefficients (share
> adds up to 1), for example:
>
> odo       bill        share
> 0.25      0.58      0.15
> 0.48      0.93      0.17
> 0.33      0.20      0.09
> 0.76      0.64      0.23
> 0.87      0.28      0.25
> 0.53      0.83      0.11
>
> I want to graph the joint distribution of odo and bill with them on
> the x axis (2 dimensions), and their joint distribution shown as
> percentages on the y axis.
>
> Thank you very much for your help in advance.
>
> Best Regards,
> Lulu
> *
> *   For searches and help try:
> *   http://www.stata.com/help.cgi?search
> *   http://www.stata.com/support/faqs/resources/statalist-faq/
> *   http://www.ats.ucla.edu/stat/stata/
*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/faqs/resources/statalist-faq/
*   http://www.ats.ucla.edu/stat/stata/


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index