简体   繁体   English

检索绘制的变更点的坐标

[英]Retrieve coordinates of plotted changepoints

I have plotted Change Points on R as 我在R上绘制了变更点为

values <- c(1, 2, 3, 4, 5, 6, 7, 8, 3, 1, 2, 3 )
values.ts = ts(values, frequency = 12, start = c(2017, 1))
chpoints = cpt.mean(values.ts, method="PELT")
cpts(chpoints)
plot(chpoints)

and the plotted graph is 绘制的图是

在此处输入图片说明

The cpts(chpoints) returns [1] 4 8 . cpts(chpoints)返回[1] 4 8

Question 1: What are [1] 4 8 ? 问题1: [1] 4 8什么?

Question 2: How can i get the coordinates of plotted change points, x,y coordinates of the red lines? 问题2:如何获得绘制的更改点的坐标,红线的x,y坐标?

Quesion 1: The cpts(chpoints) returns vector of segments' end positions. 问题1: cpts(chpoints)返回段末端位置的向量。 Following your example: 按照您的示例:

plot(chpoints)
abline(v=index(values.ts)[cpts(chpoints)[1]], col="blue") # 4
abline(v=index(values.ts)[cpts(chpoints)[2]], col="green") # 8

will add two vertical lines which indicate segment with 'stable' mean. 将添加两条垂直线,以指示“稳定”均值段。 There are no. 没有 of segments - 1 change points ( [1] 4 8 ) as the last 'change point' is the last value of your time series. 段数-1个更改点( [1] 4 8 ),因为最后一个“更改点”是时间序列的最后一个值。

Question 2: Date coordinate for i-th break can be found as: 问题2:第i个休息日的日期坐标可以找到:

index(values.ts)[cpts(chpoints)[i]]

'Stable' mean values are stored here: “稳定”平均值存储在此处:

param.est(chpoints) # 2.50 6.50 2.25

I still don't understand why there are white spaces after change points (red lines do not cover the whole time-series). 我仍然不明白为什么更改点后会有空白(红线不能覆盖整个时间序列)。 However, if we compute mean values manually: 但是,如果我们手动计算平均值:

mean(values.ts[1:cpts(chpoints)[1]] ) #
mean(values.ts[(cpts(chpoints)[1]+1):cpts(chpoints)[2]] )
mean(values.ts[(cpts(chpoints)[2]+1):length(values.ts)] ) 

we receive 2.50 6.50 2.25 as above. 我们收到上述的2.50 6.50 2.25

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM