Why does the following code not show the breakpoint dates for strucchange R package, by using the time series directly from my Excel data file?
Dummy Excel data at the bottom
library(strucchange)
df <- read_excel("breakpoint_test.xlsx")
tsrange <- read.zoo(df)
tsbreakpoint <- breakpoints(tsrange ~ 1)
summary(tsbreakpoint)
Optimal (m+1)-segment partition:
Call:
breakpoints.formula(formula = tsrange ~ 1)
Breakpoints at observation number:
m = 1 8
m = 2 7 9
m = 3 7 9 12
m = 4 4 7 9 12
m = 5 2 4 7 9 12
m = 6 2 4 7 9 11 13
Corresponding to breakdates:
m = 1 0.533333333333333
m = 2 0.466666666666667 0.6
m = 3 0.466666666666667 0.6 0.8
m = 4 0.266666666666667 0.466666666666667 0.6 0.8
m = 5 0.133333333333333 0.266666666666667 0.466666666666667 0.6 0.8
m = 6 0.133333333333333 0.266666666666667 0.466666666666667 0.6 0.733333333333333
m = 1
m = 2
m = 3
m = 4
m = 5
m = 6 0.866666666666667
Fit:
m 0 1 2 3 4 5 6
RSS 169758.9 26286.9 15077.7 4661.0 4599.3 4595.3 5012.0
BIC 188.0 165.4 162.5 150.3 155.5 160.9 167.7
Instead I have to manipulate my Excel data using ts in order for the breakpoint dates to appear in summary
tsrange2 <- ts(df$Value, start = c(2022,1), end = c(2023,3), frequency = 12)
tsbreakpoint2 <- breakpoints(tsrange2 ~ 1)
summary(tsbreakpoint2)
Optimal (m+1)-segment partition:
Call:
breakpoints.formula(formula = tsrange2 ~ 1)
Breakpoints at observation number:
m = 1 8
m = 2 7 9
m = 3 7 9 12
m = 4 4 7 9 12
m = 5 2 4 7 9 12
m = 6 2 4 7 9 11 13
Corresponding to breakdates:
m = 1 2022(8)
m = 2 2022(7) 2022(9)
m = 3 2022(7) 2022(9) 2022(12)
m = 4 2022(4) 2022(7) 2022(9) 2022(12)
m = 5 2022(2) 2022(4) 2022(7) 2022(9) 2022(12)
m = 6 2022(2) 2022(4) 2022(7) 2022(9) 2022(11) 2023(1)
Fit:
m 0 1 2 3 4 5 6
RSS 169758.9 26286.9 15077.7 4661.0 4599.3 4595.3 5012.0
BIC 188.0 165.4 162.5 150.3 155.5 160.9 167.7
Excel data:
| Dates | Value |
|---|---|
| 31-Jan-22 | 2 |
| 28-Feb-22 | 4 |
| 31-Mar-22 | 6 |
| 30-Apr-22 | 4 |
| 31-May-22 | 8 |
| 30-Jun-22 | 10 |
| 31-Jul-22 | 12 |
| 31-Aug-22 | 100 |
| 30-Sep-22 | 150 |
| 31-Oct-22 | 250 |
| 30-Nov-22 | 300 |
| 31-Dec-22 | 250 |
| 31-Jan-23 | 200 |
| 28-Feb-23 | 150 |
| 31-Mar-23 | 200 |