2017-05-24 46 views
0

我试图在两条曲线之间找到正面区域,就像在哪里只有更高的区域一样。曲线是时间序列和水平线。这是它创建的情节的图片:https://i.stack.imgur.com/ZrPH4.png。我不希望水平线更高的区域,所以我不能找到它们差异曲线下的区域。我尝试在auc函数中使用阈值参数:如何在R中的两条曲线之间找到正面区域

auc((1:96), STLFMondayBlock1$mean[(1:96)], thresh = 11648.93)但是我得到的值高于阈值:1035514没有阈值,1213062有阈值。

+1

可以将区域设为负值吗? – tagoma

+0

请提供时间序列数据。 – G5W

+0

@edouard:它可以在微积分中 – AkselA

回答

1

用一个简单的例子:

x1 <- c(0, 0, rep(1, 4), rep(0, 4), rep(1, 4), 0, 0, 0) 
x2 <- rep(0.5, length(x1)) 
d <- x1 - x2 

a <- cumsum(ifelse(d > 0, d, 0)) 
tail(a, 1) 
# 4 

par(mar=c(2, 2, 1, 1)) 
matplot(cbind(x1, x2, a), type="s", lwd=2, col=1:3) 
legend("topleft", legend="positive area between curves", 
    col=3, lty=3, lwd=2, bty="n") 

enter image description here
正如你所看到的,如果你把两条曲线和总和只有正值之间的差别,你得到的两条曲线之间的总阳性面积。