时间序列段没有拟合模型线

No fitted model line for time series segments

我使用以下时间序列:

Lines <- "D1,Value
1,20/11/2014 16:00,0.01
2,20/11/2014 17:00,0.01  
3,20/11/2014 19:00,0.01  
4,20/11/2014 22:00,0.20  
5,20/11/2014 23:00,0.03"

library (zoo)
library (strucchange)

z <- read.zoo(text = Lines, tz = "", format = "%d/%m/%Y %H:%M", sep = ",")

bp <- breakpoints(z ~ 1, h = 2)

plot(z)
abline(v = time(z)[bp$breakpoints])

我想为每个段的图形添加拟合模型,此外还创建一个具有拟合模型的截距和斜率的数据框。 对于每段图的拟合模型,我尝试使用以下内容:

lines(z, fitted(bp, breaks = 1), col = 2, lwd = 2)

但是没有线。 对于我尝试使用的数据框:

coef(bp, breaks = 1)

不过,我也需要坡度。

似乎断点 returns 一个 "ts" 对象,即使输入是 zoo 所以试试这个:

fit <- zoo(fitted(bp), time(z))
lines(fit, col = "blue", lty = 2, lwd = 2)