# [R] probabilty plot

Francisco J. Zagmutt gerifalte28 at hotmail.com
Thu Jul 5 20:11:53 CEST 2007

```Hi Zeng,

I just glanced at the link, but I think this is what you are after:

x=rnorm(1000)#1000 random samples from N(0,1)
y=rlnorm(1000)#1000 random samples from Lognormal(0,1)
fx=ecdf(x)#Empirical cumulative density function of x
fy=ecdf(y)#Empirical cumulative density function of y

#Histogram of data
hist(x)
hist(y)

n=seq(-4,30,.1)#Quantiles to be applied to the F(x)

plot(fx(n), fy(n))#Probability plot

If you are testing data against a known distribution (i.e. Normal) you
may want to use the distribution function for that distribution (i.e.
pnorm for the Normal distr) instead of the ecdf since that will provide
you with an exact answer. i.e.

plot(pnorm(n), fy(n))

Now, QQ plots are usually more useful to compare distributions since
they are more sensitive to small discrepancies in the data.  Take a look
at qqplot and qqnorm for examples of how to create qqplots in R

I hope this helps.

Francisco

along zeng wrote:
> Hi all,
>    I am a freshman of R,but I am interested  in it! Those days,I am
> learning   pages on NIST,with url
> http://www.itl.nist.gov/div898/handbook/eda/section3/probplot.htm,
> I am meeting  a problem about probability plot and I don't know how to
> plot a data set with R.
> Could somebody tell me the answer,and a example is the best!  I will