Last active
September 17, 2017 14:25
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# assuming you have a 'ts' object in R | |
# 1. install package 'strucchange' | |
# 2. Then write down this code: | |
library(strucchange) | |
# store the breakdates | |
bp_ts <- breakpoints(ts ~ 1) | |
# this will give you the break dates and their confidence intervals | |
summary(bp_ts) | |
# store the confidence intervals | |
ci_ts <- confint(bp_ts) | |
## to plot the breakpoints with confidence intervals | |
plot(ts) | |
lines(bp_ts) | |
lines(ci_ts) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment