ecdf

How to extract Ecdf value from the Ecdf() return?

不羁的心 提交于 2019-12-11 05:38:03
问题 The answer for This question here suggest a way by applying ecdf . However I am using Ecdf() from package Hmisc for it provides a convenient way to do a ccdf(Complementary Cumulative Distribution Function) plot. (by setting the what option to '1-F') By default, Ecdf() does the plot and return a nested list containing x and y . How can I extract the y value of a certain x value? and then plot it on the original plot? FYI: > str(Ecdf(rnorm(20), lwd = 2)) List of 2 $ x: num [1:21] -1.46 -1.46 -1

How do I extract ecdf values out of ecdfplot()

狂风中的少年 提交于 2019-12-07 14:21:20
问题 If I use the ecdfplot() function of the latticeExtra package how do I get the actual values calculated i.e. the y-values which correspond to the ~x|g input? I've been looking at ?ecdfplot but there's not discription to it. For the usual highlevel function ecdf() it works with the command plot=FALSE but this does not work for ecdfplot() . The reason I want to use ecdfplot() rather than ecdf() is that I need to calculate the ecdf() values for a grouping variable. I know I could do this handish

How do I extract ecdf values out of ecdfplot()

房东的猫 提交于 2019-12-05 23:08:45
If I use the ecdfplot() function of the latticeExtra package how do I get the actual values calculated i.e. the y-values which correspond to the ~x|g input? I've been looking at ?ecdfplot but there's not discription to it. For the usual highlevel function ecdf() it works with the command plot=FALSE but this does not work for ecdfplot() . The reason I want to use ecdfplot() rather than ecdf() is that I need to calculate the ecdf() values for a grouping variable. I know I could do this handish too but I'm quite convinced that there is a highroad too. Here a small expample u <- rnorm(100,0,1)

Plot density and cumulative density function in one combined plot using ggplot2

試著忘記壹切 提交于 2019-12-05 07:00:35
问题 I would like to get a plot that combines the density of observations and the cdf. The usual problem with that is that the scales of the two are way off. How can this be remedied, i.e., two scales be used or, alternatively, one of the data series be rescaled (preferably within ggplot, as I would like to separate computation and display of data). Here's the code so far: >dput(tmp) yields structure(list(drivenkm = c(8, 11, 21, 4, 594, 179, 19, 7, 10, 36)), .Names = "drivenkm", class = c("data

In R ggplot2, include stat_ecdf() endpoints (0,0) and (1,1)

断了今生、忘了曾经 提交于 2019-12-04 12:17:49
问题 I'm trying to use stat_ecdf() to plot cumulative successes as a function of a rank score created by a predictive model. #libraries require(ggplot2) require(scales) # fake data for reproducibility set.seed(123) n <- 200 df <- data.frame(model_score= rexp(n=n,rate=1:n), obs_set= sample(c("training","validation"),n,replace=TRUE)) df$model_rank <- rank(df$model_score)/n df$target_outcome <- rbinom(n,1,1-df$model_rank) # Plot Gain Chart using stat_ecdf() ggplot(subset(df,target_outcome==1),aes(x =

How to plot multiple ECDF's on one plot in different colors in R

走远了吗. 提交于 2019-12-04 10:41:34
I am trying to plot 4 ecdf functions on one plot but can't seem to figure out the proper syntax. If I have 4 functions "A, B, C, D" what would be the proper syntax in R to get them to be plotted on the same chart with different colors. Thanks! The package latticeExtra provides the function ecdfplot . library(lattice) library(latticeExtra) set.seed(42) vals <- data.frame(r1=rnorm(100)*0.5, r2=rnorm(100), r3=rnorm(100)*2) ecdfplot(~ r1 + r2 + r3, data=vals, auto.key=list(space='right') Here is one way (for three of them, works for four the same way): set.seed(42) ecdf1 <- ecdf(rnorm(100)*0.5)

R: Plotting one ECDF on top of another in different colors

这一生的挚爱 提交于 2019-12-04 03:33:59
I have a couple of cumulative empirical density functions which I would like to plot on top of each other in order to illustrate differences in the two curves. As was pointed out in a previous question , the function to draw the ECDF is simply plot(Ecdf()) And as I read the fine manual page, I determined that I can plot multiple ECDFs on top of each other using something like the following: require( Hmisc ) set.seed(3) g <- c(rep(1, 20), rep(2, 20)) Ecdf(c( rnorm(20), rnorm(20)), group=g) However my curves sometimes overlap a bit and can be hard to tell which is which, just like the example

Plot density and cumulative density function in one combined plot using ggplot2

不羁岁月 提交于 2019-12-03 21:46:02
I would like to get a plot that combines the density of observations and the cdf. The usual problem with that is that the scales of the two are way off. How can this be remedied, i.e., two scales be used or, alternatively, one of the data series be rescaled (preferably within ggplot, as I would like to separate computation and display of data). Here's the code so far: >dput(tmp) yields structure(list(drivenkm = c(8, 11, 21, 4, 594, 179, 19, 7, 10, 36)), .Names = "drivenkm", class = c("data.table", "data.frame" ), row.names = c(NA, -10L), .internal.selfref = <pointer: 0x223cb78>) then I do p =

In R ggplot2, include stat_ecdf() endpoints (0,0) and (1,1)

眉间皱痕 提交于 2019-12-03 07:49:21
I'm trying to use stat_ecdf() to plot cumulative successes as a function of a rank score created by a predictive model. #libraries require(ggplot2) require(scales) # fake data for reproducibility set.seed(123) n <- 200 df <- data.frame(model_score= rexp(n=n,rate=1:n), obs_set= sample(c("training","validation"),n,replace=TRUE)) df$model_rank <- rank(df$model_score)/n df$target_outcome <- rbinom(n,1,1-df$model_rank) # Plot Gain Chart using stat_ecdf() ggplot(subset(df,target_outcome==1),aes(x = model_rank)) + stat_ecdf(aes(colour = obs_set), size=1) + scale_x_continuous(limits=c(0,1), labels