Questions tagged [ecdf]

Empirical Cumulative Distribution Function in statistics

For definition please see its Wikipedia page.

In software, a built-in function ecdf takes a vector of samples and generates its ECDF. It is also easy to produce it ourselves, as given in this example: How to derive an ecdf function?

162 questions
4
votes
2 answers

R Highlight point on ecdf line graph

I'm creating a frequency plot using ggplot and the stat_ecdf function. I would like to add the Y-value to the graph for specific X-values, but just can't figure out how. geom_point or geom_text seems likely options, but as stat_ecdf automatically…
Gerard
  • 159
  • 1
  • 2
  • 11
4
votes
2 answers

How to smooth ecdf plots in r

I have a df with 5 variables, head(df,15) junc N1.ir N2.ir W1.ir W2.ir W3.ir 1 pos$chr1:3197398 0.000000 0.000000 0.000000 0.000000 0.000000 2 pos$chr1:3207049 0.000000 0.000000 0.000000 0.000000 0.000000 3 …
3
votes
0 answers

ECDF plot in ggplot2 without expanding count variable

I have a dataframe which looks like Height Count 173 2 184 3 193 1 Usually, to plot an empirical cumulative distribution function, one: 1) expands the dataframe by using e.g. splitstackshape's expandRows function to obtain the…
Jackk
  • 155
  • 5
3
votes
1 answer

get the derivative of an ECDF

Is it possible to differentiate an ECDF? Take the one obtained in the following for example example. set.seed(1) a <- sort(rnorm(100)) b <- ecdf(a) plot(b) I would like to take the derivative of b in order to obtain its probability density…
MaxPlank
  • 185
  • 2
  • 13
3
votes
1 answer

Input to fit a power-law to degree distribution of a network

I would like to use R to test whether the degree distribution of a network behaves like a power-law with scale-free property. Nonetheless, I've read different people doing this in many different ways, and one confusing point is the input one should…
rafa.pereira
  • 13,251
  • 6
  • 71
  • 109
3
votes
2 answers

How to plot a Complementary Cumulative Distribution Function (CCDF) in R (preferbly in ggplot)?

Here is my code and my output (CDF): install.packages("ggplot2") library(ggplot2) chol <- read.table(url("http://assets.datacamp.com/blog_assets/chol.txt"), header = TRUE) df <- data.frame(x = chol$AGE) ggplot(df, aes(x)) + stat_ecdf() I'd like…
Übel Yildmar
  • 491
  • 1
  • 9
  • 24
3
votes
2 answers

Calculate a percentile of dataframe column efficiently

This question is an extension to the StackOverflow question asked and answered here. My circumstances are different in that I want to calculate the percentile of each value within a vector of 50,000 (or more!) values. For example -- df <-…
AQS
  • 33
  • 1
  • 3
3
votes
1 answer

Empirical CDF function `ecdf` does not work for an "xts" time series

I am trying to plot the Empirical CDF of the daily returns distribution of S&P500 data. Below is the code I am trying to use. But as soon as I try to plot the ECDF, the graph doesn't look anything like a CDF graph. Please help me understand what I…
Deb
  • 295
  • 1
  • 3
  • 11
3
votes
0 answers

unexpected endpoint behavior in ggplot2::stat_ecdf()

I have some data for a gain chart. (I have percentiles of modeled scores for all the target outcomes.) > dput(data) structure(list(obs_set = structure(c(1L, 1L, 2L, 2L, 2L, 2L, 1L, 1L, 1L, 2L, 1L, 1L, 2L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,…
C8H10N4O2
  • 18,312
  • 8
  • 98
  • 134
3
votes
1 answer

Reverse x axis in ecdf plot using ggplot

How can I plot the reverse xaxis for ecdf using ggplot() function (not the qplot() function)? The following code does not work: test1 <- structure(list(ID = c(1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 51L, 52L, 53L, 54L, 55L, 56L, 57L, 58L, 59L,…
user30314
  • 183
  • 1
  • 11
3
votes
3 answers

Log Log Probability Chart in R

I'm sure this is easy, but I've been tearing my hair out trying to find out how to do this in R. I have some data that I am trying to fit to a power law distribution. To do this, you need to plot the data on a log-log cumulative probability chart.…
user2047916
  • 31
  • 1
  • 2
2
votes
1 answer

How to simulate data from a logit model

I have a logistic regression, and I would like to generate simulated data from the logit curve. My code is below: #Begin Code require(gld) runs<-100 num.trees<-500 p<-0.5 trial.1<-rgl(num.trees,1859.75592, 0.02179,…
jtgarcia
  • 21
  • 1
  • 3
2
votes
1 answer

How to plot and estimate empirical CDF and cdf in matlab

the question has already been raised several times, but mine differs a little from those previously voiced. There is a table (x value and relative frequencies). x 150 250 350 450 550 650 750 y 1 2 8 30 18 16 5 I don’t really understand…
Alex
  • 195
  • 10
2
votes
2 answers

How to use markers with ECDF plot

In order to obtain a ECDF plot with seaborn, one shall do as follows: sns.ecdfplot(data=myData, x='x', ax=axs, hue='mySeries') This will give an ECDF plot for each of the series mySeries within myData. Now, I'd like to use markers for each of these…
Lucas Aimaretto
  • 1,399
  • 1
  • 22
  • 34
2
votes
2 answers

how to find x value on a intersection point of axhline on seaborn ecdf plot?

I have a ecdf plot like this: penguins = sns.load_dataset("penguins") fig, ax = plt.subplots(figsize = (10,8)) sns.ecdfplot(data=penguins, x="bill_length_mm", hue="species") ax.axhline(.25, linestyle = '--', color ='#cfcfcf', lw = 2, alpha =…
JaySabir
  • 322
  • 1
  • 10
1
2
3
10 11