Skip to content
Back to formatted view

Raw Message

Message-ID: <x2ptniua52.fsf@biostat.ku.dk>
Date: 2003-04-19T09:08:57Z
From: Peter Dalgaard
Subject: superimposing graphs
In-Reply-To: <20030419003049.GA25335@sonny.eddelbuettel.com>

Dirk Eddelbuettel <edd at debian.org> writes:

> On Fri, Apr 18, 2003 at 07:22:58PM -0400, Faheem Mitha wrote:

> Peter has another solution in ISwR, but that may have been particular to a
> Normal distribution, and my copy is at work anyway.

(The scripts are in the ISwR package, though... End of Section 1.3 and
beginning of 1.4.) The basic principle is this

h <- hist(x, plot=F)
ylim <- range(0, h$density, dnorm(0))
hist(x, freq=F, ylim=ylim)
curve(dnorm(x), add=T)

The main point is to keep both the histogram and the curve on scale,
so it does rely on knowing that the max of the normal density is at
the mean. For an empirical density, you'll have to find its maximum
empirically, but otherwise the same technique applies.

-- 
   O__  ---- Peter Dalgaard             Blegdamsvej 3  
  c/ /'_ --- Dept. of Biostatistics     2200 Cph. N   
 (*) \(*) -- University of Copenhagen   Denmark      Ph: (+45) 35327918
~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk)             FAX: (+45) 35327907