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

# Re: st: 2 dimensional graph for joint distribution

 From Lulu Zeng <[email protected]> To "[email protected]" <[email protected]> Subject Re: st: 2 dimensional graph for joint distribution Date Fri, 1 Nov 2013 11:25:52 +1100

```Dear David and others,

Thank you for responding to my question.

"odo" and "bill" are 2 random coefficients I obtained from a fixed
mass points nonparametric choice model, "share" is the proportion of
observations at each point of "odo" and "bill", therefore gives the
probability of "odo" and "bill" at each point. Share is the same for
odo and bill, example as below (my actual model has 1,000 points).

odo     bill      share
0.26    0.30    0.34
0.89    0.56    0.25
0.41    0.73    0.41

To work out the joint probability (call it "jp") of odo and bill at
each point, I multiply the colum vector "share" with its transposed
row vector as shown in table below (jp is the centre part of the matrx
below):

bill share

0.34    0.25     0.41

0.34       0.12    0.09     0.14
odo share      0.25       0.09    0.06     0.10
0.41       0.14    0.10     0.17

For the surface graph, I want odo on x axis, bill on y axis, and jp on
z. I thought the graph may be bell sharped as jp is symetric.

In my previous email, I wasn't sure how to put jp in the graph as
-surface- needs 3 variables while my jp is a matrix.

I just figured out a potential way to solve the problem but I haven't
got the chance to try it so still unsure whether it will work. My
approach is to reshape the data -- stack all 3 colums of jp into 1
colum and match odo, bill, and jp as one to one relationships. Example
below:

odo      bill        jp
0.26    0.30    0.12
0.89    0.30    0.09
0.41    0.30    0.14
...................................
0.26    0.56    0.09
0.89    0.56    0.06
0.41    0.56    0.10
...................................
0.26    0.73    0.14
0.89    0.73    0.10
0.41    0.73    0.17

Then I will do: surface odo bill jp

Thank you again David, please let me know if you can see any problem
in my approach, any alternative approach greatly appreciated.

Best Regards,
Lulu

On Thu, Oct 31, 2013 at 10:38 PM, David Hoaglin <[email protected]> wrote:
> Dear Lulu,
>
> From your description, it appears that, for each combination of one
> value of odo and one value of bill, you have an n by n matrix that you
> would like to display.  Would you please explain that matrix further?
> In your initial message, share appeared to be a column vector, so it's
> not clear what you mean by "share multiplied by its inverse."  Also,
> what is n?
>
> Also, in an earlier message I think you said that you expected the
> joint distribution to be bell-shaped.  Why do you expect that shape?
>
> David Hoaglin
>
> On Thu, Oct 31, 2013 at 5:06 AM, Lulu Zeng <[email protected]> wrote:
>> Dear Statalist,
>>
>> My apologies for keep coming back with the same topic.
>>
>> I am trying to use -surface- to graph the joint distribution of odo
>> and bill. I want the value of odo on the x axis and bill on y axis,
>> and their joint distribution jd (a square matrix) on the z axis. jd is
>> calculated from share, which is the individual distribution of odo and
>> bill.
>>
>> I understand -surface- needs the z axis to be a singular variable,
>> however, my jd is a n by n matrix (calculated by share multiplied by
>> its inverse).
>>
>> Could you please advise if there is a way to do this?
>>
>> 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/
```