I'm making a cdf for my dataset x,y, and z. How do I put them in one plot?
Im using fitdist to obtain the ecdf and cdf for x,y, and z.
## Say if we have
x=runif(30)
y=runif(30)
z=runif(30)
## To fit the distribution I used fitdist
a=fitdist(x, "norm")
b=fitdist(y, "norm")
c=fitdist(z, "norm")
par(mfcol=c(1,3))
cdfcomp(a, xlab="yield loss", ylab="probability", main="1st Stage", datacol="black", fitcol="green")
cdfcomp(b, xlab="yield loss", ylab="probability", main="2nd Stage",datacol="gray", fitcol="blue")
cdfcomp(c, xlab="yield loss", ylab="probability",main="3rd Stage",datacol="navy", fitcol="red")
These codes give a three separate plots. Is there a way to put them in the same plot?
I tried doing
cdfcomp(list(a,b, c), horizontals = FALSE)
but it gives the following message
"Error in FUN(X[[i]], ...) :
All compared fits must have been obtained with the same dataset."
What do I do?
It is possible, use add = TRUE
:
library(fitdistrplus)
x=runif(30)
y=runif(30)
z=runif(30)
a=fitdist(x, "norm")
b=fitdist(y, "norm")
c=fitdist(z, "norm")
cdfcomp(a, xlab="yield loss", ylab="probability", datacol="black", fitcol="green")
cdfcomp(b, datacol="gray", fitcol="blue", add = TRUE)
cdfcomp(c, datacol="navy", fitcol="red", add = TRUE)