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: density plots


From   Debs Majumdar <[email protected]>
To   "[email protected]" <[email protected]>
Subject   Re: st: density plots
Date   Tue, 24 May 2011 14:47:59 -0700 (PDT)

Hi Maarten,

      Thank you for your hint. The following worked for me, although not at all elegant.

clear
set obs 100
gen x = rnormal(60,2)
gen y = rnormal(40,5)
sample 5
* I basically noted down the 5 random numbers from each distribution from these steps. Then I plotted the graph using the following:

graph twoway  (function normden(x,63,3), range(25 80)) ///
                     (function normden(x,42,5), range(25 80)) || ///
                     scatteri 0 36.84148 0 44.27059 0 45.92701 0 46.50338 0 44.33455 ///
                     0 59.50851 0 61.99597 0 68.14662 0 66.76981 0 65.88701


Thanks,
 

Debs




----- Original Message -----
From: Maarten Buis <[email protected]>
To: [email protected]
Cc: 
Sent: Tuesday, May 24, 2011 10:28 AM
Subject: Re: st: density plots

On Tue, May 24, 2011 at 6:44 PM, Debs Majumdar <[email protected]> wrote:

> I want is an x axis that ranges from 20 to 90 points  and 2 normal curves on it.
>
> One with mean 60 and standard error 2 and the other one with mean 40 and standard error 5.
>
> At last, I'd like you to pull some random values from those distributions
> and superimpose them, e.g. the numbers 1, 2, 3, ... 10 as symbols
> superimposed on top of the normal curves.

*--------------------------- begin example ---------------------------
clear
set obs 100
gen x = rnormal(60,2)
gen y = rnormal(40,5)
cumul x, gen(cx)
cumul y, gen(cy)

twoway function y = normal((x - 60)/2), range(20 90) || ///
       function y = normal((x - 40)/5), range(20 90) || ///
       scatter cx x || scatter cy y
*-------------------------- end example --------------------------------
(For more on examples I sent to the Statalist see:
http://www.maartenbuis.nl/example_faq )

Hope this helps,
Maarten

--------------------------
Maarten L. Buis
Institut fuer Soziologie
Universitaet Tuebingen
Wilhelmstrasse 36
72074 Tuebingen
Germany


http://www.maartenbuis.nl
--------------------------

*
*   For searches and help try:
*   http://www.stata.com/help.cgi?searchhttp://www.stata.com/support/statalist/faqhttp://www.ats.ucla.edu/stat/stata/


*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/


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