Extraction of ordinate and abscissa using CDF

Hello,

I have two dataframes i.e. ref and observed.
I would like to extract ordinate and abscissa for each observed 's rain value from the cumulative distribution function (CDF) of each month of ref's rain_total.

id1 <- "1JvSG10RmHbxamhvvWEVyb0AzK_9bC_2m"
id2="1Is36zNhvSSRYJA33sG6qj_C6bha6ogEe"

ref=read_csv(paste0("https://docs.google.com/uc?id=",id1,
                         "&export=download"),col_names = TRUE) 

ref=ref %>% 
  filter(month==01)
head(ref)

observed=read_csv(paste0("https://docs.google.com/uc?id=",id2,
                         "&export=download"),col_names = TRUE) 
head(observed,10)

I used the following code for CDF using 1st month

cdf <- as.data.frame(Ecdf(ref$rain_total))
cdf
plot(cdf, type="l")

Trial for ordinate and abscissa extraction:

#quantile at 20%, 50% and 80%
quantile(ecdf(ref$rain_total), c(0.2, 0.5, 0.8))

# ordinate for value 2.54,15,45
predict(loess(cdf$y ~ cdf$x), c(2.54, 15, 45))

This solution does provide a value higher than the expected value like for ordinate at 45 should not >1 and quantile 50% should be <5.08 which is not a good condition in mine case.
I will be grateful if I can get another approached like extracting from the line plot instead of the step function which I have tried.

Thanks

This topic was automatically closed 21 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.