[R] difference between two density plots

Roger Bivand Roger.Bivand at nhh.no
Thu Apr 6 21:11:33 CEST 2006


On Thu, 6 Apr 2006, Duncan Murdoch wrote:

> On 4/6/2006 1:34 PM, Philipp H. Mohr wrote:
> > Hello,
> > 
> > I have two densities which I plot with:
> > 
> > sm.density(gps)
> > sm.density(gps2)
> > 
> > Both data sets are 2D and have the same scale.
> > 
> > Is there a way of plotting the difference between the two density plots ?
> 
> ?sm.density describes the value returned by those function calls, which 
> includes "the values of the density estimate at the evaluation points". 
>    The evaluation points may be different between the two datasets, but 
> you could use approxfun to generate functions doing linear interpolation 
> for each of them, and then evaluate the density difference whereever you 
> like.

The eval.points can be set using sm.options(), fixing them to be the same.

> 
> Duncan Murdoch
> 
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
> 

-- 
Roger Bivand
Economic Geography Section, Department of Economics, Norwegian School of
Economics and Business Administration, Helleveien 30, N-5045 Bergen,
Norway. voice: +47 55 95 93 55; fax +47 55 95 95 43
e-mail: Roger.Bivand at nhh.no




More information about the R-help mailing list