Edit:
Okay, sorry i will try to be more clear,
I have 50 scenarios (here i create it randomly), and i put it all of this scenarios in a matrix. After i can apply the ecdf function, that give me a list of 50 ecdf. And i want to calculate, from all this ecdf of my 50 scenarios, the both quantiles 90 and 10 and the median.
This is a basic code:
ma <- matrix(ncol = 50, nrow = 200)
for (i in 1:50) {
x <- runif(1:200, min = 0, max = 100)
ma[,i] <- x
}
ma_ecdf <- apply(ma, 2, ecdf)
plot(ma_ecdf[[1]])
for (i in 1:50) {
lines(ma_ecdf[[i]])
}
So i can plot all of them easily, but i just want to represent the three parameters (Q10, Q50, Q90) on a graph.
Edit:
I found exactly how do it, so i share it, if sometimes someone need it.
you can try the code, the graphic is very explicit, and explains well what i wanted to do. Thx for people which tried to help me!
ma_data <- matrix(ncol = 50, nrow = 200)
for (i in 1:50) {
a <- runif(1:200, min = 0, max = 100)
ma_data[,i] <- a
}
ma_ecdf <- apply(ma_data, 2, ecdf)
x <- seq(from = 0, to = 1, by =0.1)
ma <- matrix(ncol = 50, nrow = length(x))
for (i in 1:length(x)) {
prob <- x[i]
for (j in 1:length(ma_ecdf)){
ma[i,j] <- quantile(ma_ecdf[[j]], probs = prob)
}
}
q10 <- apply(ma, 1, quantile, probs = c(0.10))
q90 <- apply(ma, 1, quantile, probs = c(0.90))
med <- apply(ma, 1, median)
plot(ma_ecdf[[1]])
for (i in 2:50) {
lines(ma_ecdf[[i]])
}
lines(med, x, type = 'o', col = 'red', lwd = 2)
lines(q90, x, type = 'o', col = 'green', lwd = 2)
lines(q10, x, type = 'o', col = 'green', lwd = 2)
You can choose to plot all the ecdf with the both quantile and median, or just the quantiles and median to make it more clear.