3
$\begingroup$

I'm learning through doing here guys, so I hope this question is considered OK (I'll edit the question down as I go - I'll remove the intro etc).

I am trying to plot the empirical cumulative distribution Frequency of a data-set with 781 observations. The data-set looks like this:

(1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 8 8 8 8 8 8 8 8 8 8 8 8 8 8 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 10 10 10 10 10 10 10 10 10 10 10 10 10 11 11 11 11 11 12 12 12 12 12 12 12 12 12 12 13 13 13 13 13 13 13 14 14 14 14 14 15 15 15 15 16 16 17 17 17 19 19 20 21 21 21 21 22 22 23 23 ).

I use the following function in R (which I pulled from r-bloggers):

plot(ecdf(V1), verticals=TRUE, pch=46)

which produces the following graph:

ECDF plot

EDIT =====

The graph plots the the actual observation on the x-axis and the percentage of observations on the y-axis.

Thank you for your help,

slotishtype

$\endgroup$
1
$\begingroup$

Well, your X-axis holds the actual value that occurred, so that is not information you want to lose (in fact, the Y axis is more indicative of the number of observations).

There are however ways to add additional axes. In your case, you could do something like this:

valsOfChoice<-seq(0,25, by=5) #at which x-es do you want to show the counts
cumnumAtVals<-sapply(valsOfChoice, function(vl){sum(V1<=vl)}) #calculate matching counts

Then after your plot, you can use:

axis(3, at=valsOfChoice, labels=cumnumAtVals)

to add a new axis to the top, holding the cumulative count in your dataset.

$\endgroup$
1
  • $\begingroup$ Thanks a million @Nick Sabbe, I now realise my mistake. I really want to be able to say that 50% of the population make up x amount of the culmative totals. So, I think I really should be using cumsum instead... So I did this "plot(cumsum(V1))", which gives me a different graph (one that makes a bit more sense). Thanks again for your help. $\endgroup$ Oct 12 '11 at 10:16
1
$\begingroup$

To be blunt, the plot you posted looks correct to me. Your data set hasn't been "reduced" to 25 variables - you only have values of the data up that far (technically only up to 23, but whose counting?). That's what that plot should show - as the value of your variable rises from 0 to 25, what percentage of the distribution is at that point or below. Your whole data is baked into the fact that the Y-axis goes from 0 to 1.

Basically, while you can plot what you're asking to plot, it's not so much a CDF at that point.

$\endgroup$
3
  • $\begingroup$ You're right, I realised my mistake when reading over nick's answer. I think I want a cumsum with percentages as opposed to a ECDF, but I am unsure of the difference. I'll edit my answer anyhow. $\endgroup$ Oct 12 '11 at 10:17
  • $\begingroup$ Might you be looking for a Density Plot, like what's covered here: statmethods.net/graphs/density.html ? $\endgroup$
    – Fomite
    Oct 12 '11 at 10:26
  • $\begingroup$ I think I am looking at the wrong thing alright. This is a distribution of user activity in system we have. Each observation is a users activity in the last month. So user 1 submitted one post while user 781 submitted 23. I want to present simple ratios like 50% of users contributed 50% of posts (similar to pareto's rule (80/20) which is not observable here). It helps to give a simple and understandable breakdown of activity but I think I am getting a little confused between approaches. $\endgroup$ Oct 12 '11 at 10:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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