Skip to content

Commit f243ee3

Browse files
committed
Fix for edge case in breakpoints(h=0.5)
1 parent 9e518db commit f243ee3

3 files changed

Lines changed: 21 additions & 16 deletions

File tree

DESCRIPTION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
Package: strucchangeRcpp
2-
Version: 1.5-4-1.0.2
2+
Version: 1.5-4-1.0.2-9999
33
Title: Testing, Monitoring, and Dating Structural Changes: C++ Version
44
Authors@R: c(person(given = "Dainius", family = "Masiliunas", role = c("aut", "cre"),
55
email = "pastas4@gmail.com", comment = c(ORCID = "0000-0001-5654-1277")),

NEWS

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
Changes in Version 1.5-4-1.0.3
2+
3+
o Fix an edge-case in breakpoints.matrix() that resulted in an unhelpful error
4+
when h = 0.5, and improve the error and warning messages in the function.
5+
16
Changes in Version 1.5-4-1.0.2
27

38
o Fix issue where breakpoints.breakpointsfull(breaks=NULL) would return

R/breakpoints.R

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -63,22 +63,22 @@ breakpoints.matrix <- function(obj, y, h = 0.15, breaks = c("BIC", "LWZ", "RSS",
6363
{
6464
breakstat <- match.arg(breaks)
6565
breaks <- ceiling(n/h) - 2
66-
} else {
67-
if (length(breaks) > 1)
68-
stop("Argument 'breaks' takes a single number or method for optimal break estimation")
69-
if (breaks %% 1 != 0)
70-
stop("Please enter an integer number of breaks")
71-
if(breaks < 1) {
72-
breaks <- 1
73-
warning("number of breaks must be at least 1")
74-
}
75-
76-
if(breaks > ceiling(n/h) - 2) {
77-
breaks0 <- breaks
78-
breaks <- ceiling(n/h) - 2
79-
warning(sprintf("requested number of breaks = %i too large, changed to %i", breaks0, breaks))
80-
}
8166
}
67+
if (length(breaks) > 1)
68+
stop("Argument 'breaks' takes a single value (number or method for optimal break estimation)")
69+
if (breaks %% 1 != 0)
70+
stop("Argument 'breaks' must evaluate to an integer number")
71+
if(breaks < 1) {
72+
breaks <- 1
73+
warning("Number of breaks must be at least 1, changed to 1")
74+
}
75+
76+
if(breaks > ceiling(n/h) - 2) {
77+
breaks0 <- breaks
78+
breaks <- ceiling(n/h) - 2
79+
warning(sprintf("requested number of breaks = %i too large, changed to %i", breaks0, breaks))
80+
}
81+
8282

8383
hpc <- match.arg(hpc)
8484
if(hpc == "foreach") {

0 commit comments

Comments
 (0)