我的数据:
require(segmented)
cp <- c(0.079, 0.079, 0.079, 0.080, 0.080, 0.081, 0.081, 0.081, 0.081, 0.081, 0.081, 0.082, 0.083, 0.084, 0.086, 0.088, 0.088, 0.088, 0.088, 0.088)
dates <- c(1443991015, 1443994615, 1443998215, 1444001815, 1444005415, 1444009015, 1444012615, 1444016215, 1444019815, 1444023415, 1444027015, 1444030615, 1444034215, 1444037815, 1444041415,
1444045015, 1444048615, 1444052215, 1444055815, 1444059415)
我会测试断点的出现。所以我做了Davies.test,正如这里建议的那样:
davies.test(lm(cp ~ dates), seg.Z = ~ dates)
但它返回p值=NA:
Davies' test for a change in the slope
data: formula = cp ~ dates , method = lm
model = gaussian , link = identity
segmented variable = dates
= , n.points = 0, p-value = NA
alternative hypothesis: two.sided
看起来davies.test
无法处理这种规模的值;内部正在发生某种溢出。
dd <- scale(dates)
davies.test(lm(cp ~ dd), seg.Z = ~ dd)
看起来效果不错。