这是我的数据(dts_trend):
> dput(dts_trend)
structure(c(NA, NA, NA, NA, NA, NA, 1.47369471844927, 2.41350194043744,
31.2688751629577, 60.4339814569159, 60.8815312225206, 66.6038819904373,
73.156936755854, 76.816641271267, 85.1805735775133, 91.3915452305811,
99.6531480201115, 117.065779757539, 127.934628844144, 131.9009947727,
109.697404628818, 94.2178211280514, 105.269315312447, 105.656646918218,
105.456594598961, 104.86750404063, 103.80636752938, 104.010655493502,
99.6228424644946, 89.3697490054001, 83.3412326343076, 86.2617376700135,
116.606572326867, 138.064609693093, 143.601054498899, 158.668783559584,
161.591992526748, 169.441389157163, 175.860044251329, 176.644686824612,
178.941999101815, 185.055281292826, 199.863946750333, 207.848664059284,
185.42263986779, 165.511071516482, 157.699795921503, 145.289484863146,
145.516461259322, 145.644524797912, 147.611673512811, 151.784984700691,
186.149216214556, 213.288955430274, 203.160103824044, 196.032345550358,
184.815433509085, 186.410986310432, 193.645954254931, 190.143864842133,
186.917926013241, 214.249350239138, 235.68370719541, 227.981549937166,
206.199821688605, 183.396956592286, 178.872793434836, NA, NA,
NA, NA, NA, NA), .Dim = c(73L, 1L), .Tsp = c(2011.91666666667,
2017.91666666667, 12), class = "ts")
我想找到断点并为其使用Strucchange包,例如关于页面上的Nile数据的示例:
https://www.r-bloggers.com/a-look-at-strucchange-and-segmented/
(当使用此页面上的Nile示例时,一切正常)
这是我的代码:
library(strucchange)
plot(dts_trend) # the plot is shown ok
bp.dts_trend <- breakpoints(dts_trend ~1) # defining breakpoints
ci.dts_trend <- confint(bp.dts_trend, breaks = 3)
lines(ci.dts_trend)
然后的问题是,代码的最后一行没有显示任何行。
只有我这样做:
plot.new()
lines(ci.dts_trend)
我在空白图上看到了三个垂直线...
我正在努力查看带有dts_trend数据和上面三行的原始图。