I need to plot a confidence band around my ecdf. I calculated a value b and I basically just need to plot ecdf+b and ecdf-b but R doesnt let me do that. Does anyone know how this can be done?


1 Answer 1


Something like this? Note that ecdf yields a function in R. (Also note that the code makes no claim to the bands reporting something "useful"; b is completely arbitrary.)

x <- rnorm(100)
Fn <- ecdf(x) 
plot(Fn, col="darkgreen", lwd=2)
b <- .1
lines(sort(x), Fn(sort(x))+b, col="salmon", lwd=2)
lines(sort(x), Fn(sort(x))-b, col="salmon", lwd=2)

enter image description here


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.