[R] Graphing measured and fitted distributions

Peter Dalgaard BSA p.dalgaard at biostat.ku.dk
Tue Sep 19 13:30:03 CEST 2000


Dermot MacSweeney <dsweeney at nmrc.ucc.ie> writes:

> Hi All,
> 
> What I would like to do is the following:
> 
> a) fit a probability function to a measured data set. This would be user 
> specified, e.g., normal, lognormal, etc. 
> 
> and then
> 
> b) take the  probability function and plot it with the  histogram of the 
> measured data set. This function would be displayed as a smooth curve. This 
> would involve "re-sizing" the probability function to match that of the measured 
> data set.

Try this for a start:

hist(rnorm(100),freq=F)
curve(dnorm(x),add=T)

This gets the units right. The main trouble is that the curve often
overshoots, so that you need to diddle the ylim and maybe also xlim on
the hist() call.

> Also I have a package which produces a jittered, one-dimensional scatter plot to 
> show the relationship of the histogram to the original data (This is plotted 
> underneath the histogram) .The X-axis contains the 
> actual data values. The y-axis is entirely random. Is it also possible to do 
> this in R. Again I can send the relevant files to interested parties on an 
> individual basis.

stripplot(x,method="jitter") for a starting point. To get the
coordination between the two plots make sure they have the same xlim
and use layout() to display them on top of eachother.

-- 
   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
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list