From: Ted Harding <Ted.Harding_at_nessie.mcc.ac.uk>

Date: Sat 19 Mar 2005 - 03:17:12 EST

E-Mail: (Ted Harding) <Ted.Harding@nessie.mcc.ac.uk> Fax-to-email: +44 (0)870 094 0861

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 03:34:02 2005

Date: Sat 19 Mar 2005 - 03:17:12 EST

On 18-Mar-05 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?
*

You can do something on the lines of:

plot(x,empDF,pch=".") ## for the empirical plot of x

lines(x0,GPD,lty="solid") ## for the GPD curve

lines(x0,Pareto,lty="dashed") ## for the Pareto curve

lines(x0,LogNormal,lty="dotdash") ## for the LogNormal curve

where x0 is a vector of (fairly finely spaced) x-values, and LogNormal, Pareto and GPD are the corresponding y-values (at each x0) for the corresponding curves.

Or the latter could be functions which computed the y-values, given the x-values, in which case you might use

lines(x0,GPD(x0),lty="solid") ## for the GPD curve

etc.

Since you're apparently beginning with R, you've encountered one of the more deeply buried (yet commonly required) aspects of R, namely how the details of a plot are set up.

You can consult the help on 'plot' and 'lines' with

?plot

?lines

but it takes a bit of poking around to find that you need to look up

?par

to find the details of things like 'lty' as used above.

You may also need to make sure that you get the axes spanning over good ranges by making your first command

plot(x,estDF,pch=".",xlim=c(a,b),ylim=c(c,d))

where a and b are the lower and upper limits for x, and c and d are those for y, since otherwise 'plot' will choose these limits in its own way depending on the ranges of values in x and in empDF, which may not be suitable for proper display of the other graphs. You can omit either or both of 'xlim' and 'ylim'.

Whatever you do about the limits, however, they will be fixed once and for all once the first plot has been drawn.

Hoping this helps,

Ted.

E-Mail: (Ted Harding) <Ted.Harding@nessie.mcc.ac.uk> Fax-to-email: +44 (0)870 094 0861

Date: 18-Mar-05 Time: 16:17:12 ------------------------------ XFMail ------------------------------ ______________________________________________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 03:34:02 2005

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