【发布时间】:2019-12-07 20:39:34
【问题描述】:
我正在使用 strucchange 包来识别我的数据中的断点,本质上是试图拟合一个阶跃函数。在某些情况下,它非常好,但在其他情况下,它完全错过了这些步骤,或者没有识别出足够多的步骤。有没有办法从本质上告诉包,它应该以更小的粒度寻找断点?
我按照这个例子找到了断点:Model comparison for breakpoint time series model in R strucchange
我使用的代码在这里:
ts_prep <- data.frame(newdata$Num_Cycles)
newdata_ts <- ts(data=ts_prep, start = c(1,1), frequency=num)
plot(newdata_ts,main=num)
break_points <- breakpoints(newdata_ts ~ 1)
break_factor <- breakfactor(break_points)
break_model <- lm(newdata_ts ~ break_factor - 1)
lines(fitted(break_points), col = 4)
simple_lm <- lm(newdata_ts ~ time(newdata_ts))
abline(simple_lm,col='red')
【问题讨论】:
标签: r breakpoints