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. How I can do it? Can the ecdf() command still help me?
Asked
Active
Viewed 3,627 times
2
-
Thanx dear, let me ask my question more specifically I have estimated parameters of "loglogistic distribution" I want to compare cdf of loglogistic distribution with emperical cdf how can i compare it visually.I have plottd the empirical cdf using ecdf().the plotting of LL cdf remains. – user2881894 Oct 15 '13 at 10:26
-
1This is a coding site. Post code. – IRTFM Oct 15 '13 at 15:40
1 Answers
1
Yes, ecdf
can help you. 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
.
# 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)
![](../../users/profiles/2591234.webp)
shadow
- 20,147
- 4
- 49
- 71
-
Thanx dear, let me ask my question more specifically I have estimated parameters of "loglogistic distribution" I want to compare cdf of loglogistic distribution with emperical cdf how can i compare it visually.I have plottd the empirical cdf using ecdf().the plotting of LL cdf remains. – user2881894 Oct 15 '13 at 10:31