Re: [R] How to create a 'fit' plot

From: Adaikalavan Ramasamy <ramasamy_at_cancer.org.uk>
Date: Sat 19 Mar 2005 - 06:44:33 EST

If you know the exact formulae for the distribution, replace it with 'f' function below. You may want to use the log="x" in the plot.

 f <- function(x) 1 - exp( -x/20 );
 plot( f, xlim=c(0,100), ylim=c(0.5, 1) )

Otherwise generate sufficient realisations from it and fit a line as below

 x <- seq(-5,5,by=0.01)
 y <- dt(x, 5)
 plot( x, y, type="l", col=8 )

Now you can overlay the observations as points

 obs.x <- rnorm(50)
 obs.y <- runif(50)
 points( obs.x, obs.y, pch=18)

You might want to see help("plot"), help("par") or demo(graphics) as well as http://www.r-project.org/other-docs.html

Regards, Adai

On Fri, 2005-03-18 at 07:18 -0800, R_xprt_wannabe wrote:
> Dear List,
>
> As someone who is in the process of trying to migrate
> from Excel, I'd appreciate any help on this question:
>
> I have a data set and want to fit, say, three
> distributions to it. I would like to create a plot
> that shows my data points against all three fitted
> curves (estimated d.f.). Basically, I lookint to
> creat a plot that looks like the one presented in the
> attached paper (Figure 5, page 12):
>
> http://www.math.ethz.ch/~mcneil/ftp/astin.pdf
>
>
> Could you please show me, or point me to example code
> showing, how that can be done?
>
> Thanks,
>
> ______________________________________________
> R-help@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
>



R-help@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 Received on Sat Mar 19 06:49:12 2005

This archive was generated by hypermail 2.1.8 : Fri 03 Mar 2006 - 03:30:51 EST