Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down on April 23, and its replacement, is already up and running.

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

st: plot 3 normal distribution on one graph

From   yannan shen <>
Subject   st: plot 3 normal distribution on one graph
Date   Tue, 6 Nov 2012 01:24:01 -0500

Dear statalist,
I need to plot three normal distributions on one graph, I want them to
be over each other, not side by side.
The three distributions are:
y1~norm(1, 2)
y2~norm (3, 4)
y3 is a weighted average of y1 and y2, let's say  y3=.5*y1+.5*y2

I found the following code from previous statalist discussion that
looks very helpful:

/* Plot two normal distributions */
#delimit ;
graph twoway (function y=normalden(x,1,2), range(-10 20) lw(medthick))
             (function y=normalden(x,5,3), range(-10 20) lw(medthick)),
title("Normal-Distribution comparison")
xtitle("Normal", size(medlarge)) ytitle("")
xscale(lw(medthick)) yscale(lw(medthick))
#delimit cr
/* Stata code ends */

However, I copied and pasted the exact code into stata command window
and the first line returns an error message "Unknown #command"

Why??? I googled the error message but was not able to find a
solution. I cleared the program history, closed and reopned stata, and
tried on different computers, but was unable to find spot the problem.
Can someone please help me? I am using stata IC 12.0

Thank you very much!
*   For searches and help try:

© Copyright 1996–2016 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index