[英]How to plot estimated CDF with empirical CDF
I am fitting a distribution to a given data.then I have estimated parameters of the distribution.I have also plotted the empirical cdf using ecdf() command in R. Now I have to plot cdf of estimated distribution along with empirical cdf. 我将分布拟合到给定的数据,然后我估计了分布的参数。我还使用R中的ecdf()命令绘制了经验cdf。现在我必须将估计分布的cdf与经验cdf一起绘制。 How I can do it?
我该怎么办? Can the ecdf() command still help me?
ecdf()命令还能帮助我吗?
Yes, ecdf
can help you. 是的,
ecdf
可以为您提供帮助。 It has a plotting method. 它具有绘图方法。 Below you see possible code for a normal distribution.
在下面,您可以看到正态分布的可能代码。
x <- rnorm(100)
plot(ecdf(x))
lines(seq(-3, 3, by=.1), pnorm(seq(-3, 3, by=.1)), col=2)
EDIT: You can do the same thing using the log-logistic distribution function instead. 编辑:您可以使用对数逻辑分布函数来做同样的事情。 It is implemented for instance in package
actuar
. 据例如在包中实现
actuar
。
# load package
require(actuar)
# check out the parametrization!
?dllogis
# estimate shape and scale from your data
shape <- 20
scale <- 1
# Don't do this. Use your own data instead.
x <- rllogis(100, shape=shape, scale=scale)
# Plotting the empirical distribution function
plot(ecdf(x))
# x-values for plotting distribution function
xvals <- seq(min(x), max(x), length=100)
# plot estimated distribution function with your estimated shape and scale
lines(xvals, pllogis(xvals, shape=shape, scale=scale), col=2)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.