Hello all, I would like to plot the emperical CDF, normal CDF and pareto CDF in the same graph and I amusing the following codes. "z" is a vector and I just need the part when z between 1.6 and 3. plot(ecdf(z), do.points=FALSE, verticals=TRUE, xlim=c(1.6,3),ylim=c(1-sum(z>1.6)/length(z), 1)) x <- seq(1.6, 3, 0.1) lines(x,pgpd(x, 1.544,0.4373,-0.2398), col="red") y <- seq(1.6, 3, 0.1) lines(y,pnorm(y, mean(z),sqrt(var(z))), col="blue") The emperical CDF and normal CDF look rather resonable, but the pareto CDF looks quite odd. I am not sure whether I plot the pareto CDF correctly e.g. in the right yaxs or any other mistake? At the same time, let "t" represents the vector whose values are larger than 1.6(the part we want). If I implement the following codes and plot the emperical CDF and pareto CDF, the pareto CDF seems fit. plot(ecdf(t), do.points=FALSE, verticals=TRUE) x <- seq(1.6, 3, 0.1) lines(x,pgpd(x, 1.544,0.4373,-0.2398), col="red") Could anyone give me some advice on this? Many thanks. -- View this message in context: http://www.nabble.com/ECDF%2C-distribution-of-Pareto%2C-distribution-of-Normal-tf4056943.html#a11524560 Sent from the R help mailing list archive at Nabble.com.

Stefan Grosse

2007-Jul-10 17:30 UTC

### [R] ECDF, distribution of Pareto, distribution of Normal

-------- Original Message -------- Subject: [R] ECDF, distribution of Pareto, distribution of Normal From: livia <yn19832 at msn.com> To: r-help at stat.math.ethz.ch Date: Tue Jul 10 2007 18:35:04 GMT+0200> Hello all, > > I would like to plot the emperical CDF, normal CDF and pareto CDF in the > same graph and I amusing the following codes. "z" is a vector and I just > need the part when z between 1.6 and 3. > > plot(ecdf(z), do.points=FALSE, verticals=TRUE, > xlim=c(1.6,3),ylim=c(1-sum(z>1.6)/length(z), 1)) > > x <- seq(1.6, 3, 0.1) > lines(x,pgpd(x, 1.544,0.4373,-0.2398), col="red") >There is something wrong with your pgpd function, see ?pgpd for help and parameters... (I wonder how you got something plotted here...)> y <- seq(1.6, 3, 0.1) > lines(y,pnorm(y, mean(z),sqrt(var(z))), col="blue") > > The emperical CDF and normal CDF look rather resonable, but the pareto CDF > looks quite odd. I am not sure whether I plot the pareto CDF correctly e.g. > in the right yaxs or any other mistake? > > At the same time, let "t" represents the vector whose values are larger than > 1.6(the part we want). If I implement the following codes and plot the > emperical CDF and pareto CDF, the pareto CDF seems fit. > > plot(ecdf(t), do.points=FALSE, verticals=TRUE) > x <- seq(1.6, 3, 0.1) > lines(x,pgpd(x, 1.544,0.4373,-0.2398), col="red") > > Could anyone give me some advice on this? Many thanks. >

Thank you very much for your reply. I am afraid I have no idea what is wrong with the pgpg function. The parameters are generated from pre-fitted GPD distribution. 1.544 is the location parameter, 0.4373 is the scale parameter and -0.2398 is the shape parameter. Cound you please give me some hint? Stefan Grosse-2 wrote:> > > > -------- Original Message -------- > Subject: [R] ECDF, distribution of Pareto, distribution of Normal > From: livia <yn19832 at msn.com> > To: r-help at stat.math.ethz.ch > Date: Tue Jul 10 2007 18:35:04 GMT+0200 >> Hello all, >> >> I would like to plot the emperical CDF, normal CDF and pareto CDF in the >> same graph and I amusing the following codes. "z" is a vector and I just >> need the part when z between 1.6 and 3. >> >> plot(ecdf(z), do.points=FALSE, verticals=TRUE, >> xlim=c(1.6,3),ylim=c(1-sum(z>1.6)/length(z), 1)) >> >> x <- seq(1.6, 3, 0.1) >> lines(x,pgpd(x, 1.544,0.4373,-0.2398), col="red") >> > > There is something wrong with your pgpd function, see ?pgpd for help and > parameters... (I wonder how you got something plotted here...) > > >> y <- seq(1.6, 3, 0.1) >> lines(y,pnorm(y, mean(z),sqrt(var(z))), col="blue") >> >> The emperical CDF and normal CDF look rather resonable, but the pareto >> CDF >> looks quite odd. I am not sure whether I plot the pareto CDF correctly >> e.g. >> in the right yaxs or any other mistake? >> >> At the same time, let "t" represents the vector whose values are larger >> than >> 1.6(the part we want). If I implement the following codes and plot the >> emperical CDF and pareto CDF, the pareto CDF seems fit. >> >> plot(ecdf(t), do.points=FALSE, verticals=TRUE) >> x <- seq(1.6, 3, 0.1) >> lines(x,pgpd(x, 1.544,0.4373,-0.2398), col="red") >> >> Could anyone give me some advice on this? Many thanks. >> > > ______________________________________________ > 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 > and provide commented, minimal, self-contained, reproducible code. > >-- View this message in context: http://www.nabble.com/ECDF%2C-distribution-of-Pareto%2C-distribution-of-Normal-tf4056943.html#a11536305 Sent from the R help mailing list archive at Nabble.com.

J. R. M. Hosking

2007-Jul-11 14:19 UTC

### [R] ECDF, distribution of Pareto, distribution of Normal

livia wrote:> Hello all, > > I would like to plot the emperical CDF, normal CDF and pareto CDF in the > same graph and I amusing the following codes. "z" is a vector and I just > need the part when z between 1.6 and 3. > > plot(ecdf(z), do.points=FALSE, verticals=TRUE, > xlim=c(1.6,3),ylim=c(1-sum(z>1.6)/length(z), 1)) > > x <- seq(1.6, 3, 0.1) > lines(x,pgpd(x, 1.544,0.4373,-0.2398), col="red") > > y <- seq(1.6, 3, 0.1) > lines(y,pnorm(y, mean(z),sqrt(var(z))), col="blue") > > The emperical CDF and normal CDF look rather resonable, but the pareto CDF > looks quite odd. I am not sure whether I plot the pareto CDF correctly e.g. > in the right yaxs or any other mistake? > > At the same time, let "t" represents the vector whose values are larger than > 1.6(the part we want). If I implement the following codes and plot the > emperical CDF and pareto CDF, the pareto CDF seems fit. > > plot(ecdf(t), do.points=FALSE, verticals=TRUE) > x <- seq(1.6, 3, 0.1) > lines(x,pgpd(x, 1.544,0.4373,-0.2398), col="red") > > Could anyone give me some advice on this? Many thanks.If any of your data points are less than 1.6, ecdf(z) and ecdf(t) will be different functions: for arguments greater than 1.6, the former will take values in c(mean(z<1.6),1) and the latter will cover the range (0,1). It is not surprising that your pgpd function will fit only one of these empirical cdf''s closely. Assuming that those GPD parameters were obtained by fitting to just the data values greater than 1.6, the GPD curve in your first plot should be u<-mean(z<1.6) x<-seq(1.6,3,0.1) lines(x, u + (1-u)*pgpd(x, <parameters> ) J. R. M. Hosking