abscissa and ordinate from CDF plot

Hello everyone,
How can I get both ordinate and abscissa from the CDF plot?

For example, in the code below; I want to have ordinate for x-value=50.
Likewise, x-value when y-value=0.5.

Thanks

set.seed(1000)
a <- rnorm(10000, 1, 100)
aCDFcolor <- rgb(1,0,0)
plot(ecdf(a), col=aCDFcolor, main=NA)

Hi @meitei,
Try this:

set.seed(1000)
a <- rnorm(10000, 1, 100)
aCDFcolor <- rgb(1,0,0)
plot(ecdf(a), col=aCDFcolor, main=NA)

summary(ecdf(a))
#> Empirical CDF:     10000 unique values with summary
#>     Min.  1st Qu.   Median     Mean  3rd Qu.     Max. 
#> -355.179  -66.385    0.873    1.115   68.902  374.914

# Abscissa (x) from ordinate (y)
quantile(ecdf(a), c(0.2, 0.5, 0.8))
#>        20%        50%        80% 
#> -83.123396   0.872981  85.676709

# Ordinate from abscissa (bit clunky; must be a better way?)
library(Hmisc)
#> Loading required package: lattice
#> Loading required package: survival
#> Loading required package: Formula
#> Loading required package: ggplot2
#> 
#> Attaching package: 'Hmisc'
#> The following objects are masked from 'package:base':
#> 
#>     format.pval, units

Ecdf(a)

temp <- as.data.frame(Ecdf(a))

predict(loess(temp$y ~ temp$x), c(-100, 50, 180))
#> [1] 0.1605665 0.6833963 0.9724153

Created on 2020-12-15 by the reprex package (v0.3.0)

1 Like

Could you further check why the quantiles are not estimated proportionately?
For example:

set.seed(10)
dat=runif(50,0,100)
cdf <- as.data.frame(Ecdf(dat))
colnames(cdf)=c("Temperature","probability")

temp=30

(percentile=predict(loess(cdf$probability ~ cdf$Temperature), temp))
set.seed(1000)
(u1 <- runif(1, 0, percentile))
(d1 <- quantile(ecdf(cdf$Temperature), u1))
d1=as.vector(d1)
percentile2=predict(loess(cdf$probability ~ cdf$Temperature),(temp-d1))
(u2=runif(1, 0, percentile2))                   
d2 <- ifelse(d1 <= temp,
             quantile(ecdf(cdf$Temperature),u2),
          0 )
d3 <- temp - (d1 + d2)

In the code above, I am expecting the temp=30 is disaggregated into 3 parts using the CDF.
The Sum of three parts should equal to temp.
However, I find d2>d1 in spite of having a lower percentile (i.e. percentile of d2<d1 so it should have a lower quantile).

Thanks

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.

Thanks, @DavoWW ..!!