由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Statistics版 - How to compute the area between my curve and diagonal line
相关主题
[R] ROC curve怎么指定cutoffs?问一个关于R 的问题
roc curve in RROC curve可以用来比较变量吗
2个初级的R问题: 包子答谢!How to calculate Area Under the Effect Curve(AUEC)?
为什么不能把ABLINE加到散点图中了R question
看似简单,但是竟然不会做。做Markov chain Monte Carlo 是用matlab 还是R 快一点,都各自有现成的函数可以调用吗?
How to calculate the area under a curve if just know values of x and y?How to plot multi-curves in one single chart by R
R-square of logistic regression求推荐一下Bayesian入门教材
对比曲线的形状有什么方法吗?C++还是房地产价格分析,选课建议
相关话题的讨论汇总
话题: area话题: diagonal话题: compute话题: curve话题: between
进入Statistics版参与讨论
1 (共1页)
S******y
发帖数: 1123
1
How can I compute the area between my curve and diagonal line?
Thanks.
Is MCMC a good solution?
> x<-c(0,0.2,0.4,0.6,.8,.9,.95,.99,1)
> y<-c(0,0.1,0.15,0.3,0.7,.9,.94,.98,1)
> plot(x,y,type='l')
> abline(0,1)
o****o
发帖数: 8077
2
man, you got 8 Ti Xing, and you know how to calculate Ti Xing area
x<-c(0,0.2,0.4,0.6,.8,.9,.95,.99,1)
y<-c(0,0.1,0.15,0.3,0.7,.9,.94,.98,1)
plot(x,y,type='l')
abline(0,1)
xl<-length(x)
z<-1:(xl-1)
l<-x;
for (i in 1:(xl-1)){
d1<-l[i]-y[i]; d2<-l[i+1]-y[i+1]; h<-x[i+1]-x[i];
z[i]<-0.5*h*(d1+d2);
}
sum(z)

correct me if I am wrong

【在 S******y 的大作中提到】
: How can I compute the area between my curve and diagonal line?
: Thanks.
: Is MCMC a good solution?
: > x<-c(0,0.2,0.4,0.6,.8,.9,.95,.99,1)
: > y<-c(0,0.1,0.15,0.3,0.7,.9,.94,.98,1)
: > plot(x,y,type='l')
: > abline(0,1)

D******n
发帖数: 2836
3
ppl also use the zigzag version of AUC calculation too

【在 o****o 的大作中提到】
: man, you got 8 Ti Xing, and you know how to calculate Ti Xing area
: x<-c(0,0.2,0.4,0.6,.8,.9,.95,.99,1)
: y<-c(0,0.1,0.15,0.3,0.7,.9,.94,.98,1)
: plot(x,y,type='l')
: abline(0,1)
: xl<-length(x)
: z<-1:(xl-1)
: l<-x;
: for (i in 1:(xl-1)){
: d1<-l[i]-y[i]; d2<-l[i+1]-y[i+1]; h<-x[i+1]-x[i];

s*r
发帖数: 2757
4
应该尽量用vector操作

【在 o****o 的大作中提到】
: man, you got 8 Ti Xing, and you know how to calculate Ti Xing area
: x<-c(0,0.2,0.4,0.6,.8,.9,.95,.99,1)
: y<-c(0,0.1,0.15,0.3,0.7,.9,.94,.98,1)
: plot(x,y,type='l')
: abline(0,1)
: xl<-length(x)
: z<-1:(xl-1)
: l<-x;
: for (i in 1:(xl-1)){
: d1<-l[i]-y[i]; d2<-l[i+1]-y[i+1]; h<-x[i+1]-x[i];

S******y
发帖数: 1123
5
Thank both of you!
I just found out this code seems working too -
x<-c(0,0.2,0.4,0.6,.8,.9,.95,.99,1)
y<-c(0,0.1,0.15,0.3,0.7,.9,.94,.98,1)
n <- length(x)
0.5 * abs(sum(x[-1] * y[-n]) - sum(x[-n] * y[-1]) )
o****o
发帖数: 8077
6
就是想给个quick solution。vectorized的程序还没想好,实际问题已经解决了

【在 s*r 的大作中提到】
: 应该尽量用vector操作
a********s
发帖数: 188
7
It is a simple case here. Using the quadrilateral idea to get the area is
quick. If you want the area for any one-dimensional function, you may use "
integrate" in R once you know the explicit function. But it is slow.
o****o
发帖数: 8077
8
这个不错

【在 S******y 的大作中提到】
: Thank both of you!
: I just found out this code seems working too -
: x<-c(0,0.2,0.4,0.6,.8,.9,.95,.99,1)
: y<-c(0,0.1,0.15,0.3,0.7,.9,.94,.98,1)
: n <- length(x)
: 0.5 * abs(sum(x[-1] * y[-n]) - sum(x[-n] * y[-1]) )

S******y
发帖数: 1123
9
Thanks oloolo!
How can I prove that my approch is equivalent to yours mathematically?
o****o
发帖数: 8077
10
呵呵,我不知道R可以用负值小标代表去掉这个元素,又学习了
这么算来,我的那个loopy可以写成这个向量表达式(满足sir一下)
(x[-n]-y[-n]+x[-1]-y[-1])*(x[-1]-x[-n])
全部展开,并且注意到你的x和y向量的首尾元素是一样的,这样
(x[n]^2-x[1]^2 )-(x[n]*y[n] - x[1]*y[1])=0
最后剩下的就是你那个命令了

【在 S******y 的大作中提到】
: Thanks oloolo!
: How can I prove that my approch is equivalent to yours mathematically?

1 (共1页)
进入Statistics版参与讨论
相关主题
C++还是房地产价格分析,选课建议看似简单,但是竟然不会做。
一道概率题How to calculate the area under a curve if just know values of x and y?
How to put confidence interval on a KM curve?R-square of logistic regression
Statistician在药厂里究竟都做些什么呢?对比曲线的形状有什么方法吗?
[R] ROC curve怎么指定cutoffs?问一个关于R 的问题
roc curve in RROC curve可以用来比较变量吗
2个初级的R问题: 包子答谢!How to calculate Area Under the Effect Curve(AUEC)?
为什么不能把ABLINE加到散点图中了R question
相关话题的讨论汇总
话题: area话题: diagonal话题: compute话题: curve话题: between