Skip to content

Commit

Permalink
Update fastcpd 0.14.1
Browse files Browse the repository at this point in the history
*   Fix possible numeric issues on CRAN breaking updates of other packages.
  • Loading branch information
doccstat committed Apr 18, 2024
1 parent f087793 commit 6c6cb57
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 46 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Type: Package
Package: fastcpd
Title: Fast Change Point Detection via Sequential Gradient Descent
Version: 0.14.0
Version: 0.14.1
Authors@R: c(
person("Xingchi", "Li", , "[email protected]",
role = c("aut", "cre", "cph"),
Expand Down
4 changes: 4 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# fastcpd 0.14.1

* Fix possible numeric issues on CRAN breaking updates of other packages.

# fastcpd 0.14.0

* Correct mBIC.
Expand Down
15 changes: 2 additions & 13 deletions cran-comments.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,5 @@
## Updates since last CRAN release (0.13.1)

### fastcpd 0.14.0
### fastcpd 0.14.1

* Correct mBIC.
* Add citation.

### fastcpd 0.13.2

* Remove package check in examples.
* Use proper pruning coefficients for MBIC and MDL.
* Make residuals matrices.
* Use preprocess for faster mean change detection.
* Update examples demonstrating faster mean change.
* Replace comparison packages in vignettes with strange dependencies with
results and `eval = FALSE`.
* Fix possible numeric issues on CRAN breaking updates of other packages.
69 changes: 37 additions & 32 deletions vignettes/comparison-packages.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -240,15 +240,15 @@ Some methods are plotted due to the un-retrievable change points.
```

```{r univariate-mean-change-fastcpd-testthat, include = FALSE}
testthat::expect_equal(fastcpd_result, c(300, 700))
testthat::expect_equal(fastcpd_result, c(300, 700), tolerance = 0.2)
```

```{r univariate-mean-change-CptNonPar}
(CptNonPar_result <- CptNonPar::np.mojo(mean_data_1, G = floor(length(mean_data_1) / 6))$cpts)
```

```{r univariate-mean-change-CptNonPar-testthat, include = FALSE}
testthat::expect_equal(CptNonPar_result, c(300, 700))
testthat::expect_equal(CptNonPar_result, c(300, 700), tolerance = 0.2)
```

```{r univariate-mean-change-strucchange, eval = FALSE}
Expand All @@ -266,23 +266,23 @@ ecp::e.divisive(mean_data_1)$estimates
```

```{r univariate-mean-change-changepoint-testthat, include = FALSE}
testthat::expect_equal(changepoint_result, c(300, 1000))
testthat::expect_equal(changepoint_result, c(300, 1000), tolerance = 0.2)
```

```{r univariate-mean-change-breakfast}
(breakfast_result <- breakfast::breakfast(mean_data_1)$cptmodel.list[[6]]$cpts)
```

```{r univariate-mean-change-breakfast-testthat, include = FALSE}
testthat::expect_equal(breakfast_result, c(300, 700))
testthat::expect_equal(breakfast_result, c(300, 700), tolerance = 0.2)
```

```{r univariate-mean-change-wbs}
(wbs_result <- wbs::wbs(mean_data_1)$cpt$cpt.ic$mbic.penalty)
```

```{r univariate-mean-change-wbs-testthat, include = FALSE}
testthat::expect_equal(wbs_result, c(300, 700))
testthat::expect_equal(wbs_result, c(300, 700), tolerance = 0.2)
```

```{r univariate-mean-change-mosum, eval = FALSE}
Expand All @@ -295,7 +295,7 @@ mosum::mosum(c(mean_data_1), G = 40)$cpts.info$cpts
```

```{r univariate-mean-change-fpop-testthat, include = FALSE}
testthat::expect_equal(fpop_result, c(300, 700, 1000))
testthat::expect_equal(fpop_result, c(300, 700, 1000), tolerance = 0.2)
```

```{r univariate-mean-change-gfpop, eval = FALSE}
Expand Down Expand Up @@ -332,7 +332,7 @@ result_InspectChangepoint$changepoints[, "location"]
```

```{r univariate-mean-change-jointseg-testthat, include = FALSE}
testthat::expect_equal(jointseg_result, c(300, 700))
testthat::expect_equal(jointseg_result, c(300, 700), tolerance = 0.2)
```

```{r univariate-mean-change-Rbeast, eval = FALSE}
Expand All @@ -347,26 +347,25 @@ Rbeast::beast(
```

```{r univariate-mean-change-stepR-testthat, include = FALSE}
testthat::expect_equal(stepR_result, c(300, 700, 1000))
testthat::expect_equal(stepR_result, c(300, 700, 1000), tolerance = 0.2)
```

```{r univariate-mean-change-cpm}
(cpm_result <- cpm::processStream(mean_data_1, cpmType = "Student")$changePoints)
```

```{r univariate-mean-change-cpm-testthat, include = FALSE}
testthat::expect_equal(cpm_result, c(299, 699))
testthat::expect_equal(cpm_result, c(299, 699), tolerance = 0.2)
```

```{r univariate-mean-change-segmented}
(segmented_result <- segmented::segmented(
lm(y ~ 1 + x, data.frame(y = mean_data_1, x = seq_len(nrow(mean_data_1)))),
seg.Z = ~ x
(segmented_result <- segmented::stepmented(
as.numeric(mean_data_1), npsi = 2
)$psi[, "Est."])
```

```{r univariate-mean-change-segmented-testthat, include = FALSE}
testthat::expect_equal(segmented_result, c(495))
testthat::expect_equal(segmented_result, c(298, 699), tolerance = 0.2)
```

```{r univariate-mean-change-mcp, eval = FALSE}
Expand Down Expand Up @@ -401,7 +400,7 @@ Some methods are plotted due to the un-retrievable change points.
```

```{r univariate-mean-and-or-variance-change-fastcpd-testthat, include = FALSE}
testthat::expect_equal(fastcpd_result, c(300, 700, 1001, 1300, 1700))
testthat::expect_equal(fastcpd_result, c(300, 700, 1001, 1300, 1700), tolerance = 0.2)
```

```{r univariate-mean-and-or-variance-change-ecp, eval = FALSE}
Expand All @@ -414,23 +413,23 @@ ecp::e.divisive(mv_data_1)$estimates
```

```{r univariate-mean-and-or-variance-change-changepoint-testthat, include = FALSE}
testthat::expect_equal(changepoint_result, c(300, 2000))
testthat::expect_equal(changepoint_result, c(300, 2000), tolerance = 0.2)
```

```{r univariate-mean-and-or-variance-change-CptNonPar}
(CptNonPar_result <- CptNonPar::np.mojo(mv_data_1, G = floor(length(mv_data_1) / 6))$cpts)
```

```{r univariate-mean-and-or-variance-change-CptNonPar-testthat, include = FALSE}
testthat::expect_equal(CptNonPar_result, c(333, 700, 1300))
testthat::expect_equal(CptNonPar_result, c(333, 700, 1300), tolerance = 0.2)
```

```{r univariate-mean-and-or-variance-change-cpm}
(cpm_result <- cpm::processStream(mv_data_1, cpmType = "GLR")$changePoints)
```

```{r univariate-mean-and-or-variance-change-cpm-testthat, include = FALSE}
testthat::expect_equal(cpm_result, c(293, 300, 403, 408, 618, 621, 696, 1000, 1021, 1024, 1293, 1300, 1417, 1693, 1700, 1981))
testthat::expect_equal(cpm_result, c(293, 300, 403, 408, 618, 621, 696, 1000, 1021, 1024, 1293, 1300, 1417, 1693, 1700, 1981), tolerance = 0.2)
```

```{r univariate-mean-and-or-variance-change-InspectChangepoint, eval = FALSE}
Expand Down Expand Up @@ -503,15 +502,15 @@ Some methods are plotted due to the un-retrievable change points.
```

```{r multivariate-mean-change-fastcpd-testthat, include = FALSE}
testthat::expect_equal(fastcpd_result, c(300, 700))
testthat::expect_equal(fastcpd_result, c(300, 700), tolerance = 0.2)
```

```{r multivariate-mean-change-CptNonPar}
(CptNonPar_result <- CptNonPar::np.mojo(mean_data_3, G = floor(nrow(mean_data_3) / 6))$cpts)
```

```{r multivariate-mean-change-CptNonPar-testthat, include = FALSE}
testthat::expect_equal(CptNonPar_result, c(300, 700))
testthat::expect_equal(CptNonPar_result, c(300, 700), tolerance = 0.2)
```

```{r multivariate-mean-change-InspectChangepoint, eval = FALSE}
Expand All @@ -536,7 +535,7 @@ result_InspectChangepoint$changepoints[, "location"]
```

```{r multivariate-mean-change-jointseg-testthat, include = FALSE}
testthat::expect_equal(jointseg_result, c(300, 700))
testthat::expect_equal(jointseg_result, c(300, 700), tolerance = 0.2)
```

```{r multivariate-mean-change-Rbeast, eval = FALSE}
Expand Down Expand Up @@ -594,7 +593,7 @@ Some methods are plotted due to the un-retrievable change points.
```

```{r multivariate-mean-and-or-variance-change-fastcpd-testthat, include = FALSE}
testthat::expect_equal(fastcpd_result, c(300, 700, 1000, 1300, 1700))
testthat::expect_equal(fastcpd_result, c(300, 700, 1000, 1300, 1700), tolerance = 0.2)
```

```{r multivariate-mean-and-or-variance-change-ecp, eval = FALSE}
Expand Down Expand Up @@ -683,7 +682,7 @@ The true change points are 100 and 200.
```

```{r linear-regression-fastcpd-testthat, include = FALSE}
testthat::expect_equal(fastcpd_result, c(97, 201))
testthat::expect_equal(fastcpd_result, c(97, 201), tolerance = 0.2)
```

```{r linear-regression-strucchange, eval = FALSE}
Expand All @@ -702,7 +701,7 @@ strucchange::breakpoints(y ~ . - 1, data = lm_data)$breakpoints
```

```{r linear-regression-segmented-testthat, include = FALSE}
testthat::expect_lt(segmented_result - 233, 1)
testthat::expect_equal(segmented_result, c(233), tolerance = 0.2)
```

# Logistic regression
Expand All @@ -714,7 +713,7 @@ The true change point is 300.
```

```{r logistic-regression-fastcpd-testthat, include = FALSE}
testthat::expect_equal(fastcpd_result, 302)
testthat::expect_equal(fastcpd_result, 302, tolerance = 0.2)
```

```{r logistic-regression-strucchange, eval = FALSE}
Expand All @@ -731,7 +730,7 @@ The true change points are 500, 800 and 1000.
```

```{r poisson-regression-fastcpd-testthat, include = FALSE}
testthat::expect_equal(fastcpd_result, c(498, 805, 1003))
testthat::expect_equal(fastcpd_result, c(498, 805, 1003), tolerance = 0.2)
```

```{r poisson-regression-strucchange, eval = FALSE}
Expand Down Expand Up @@ -766,15 +765,15 @@ Some methods are plotted due to the un-retrievable change points.
```

```{r ar3-fastcpd-testthat, include = FALSE}
testthat::expect_equal(fastcpd_result, c(614))
testthat::expect_equal(fastcpd_result, c(614), tolerance = 0.2)
```

```{r ar3-CptNonPar}
(CptNonPar_result <- CptNonPar::np.mojo(ar_data, G = floor(length(ar_data) / 6))$cpts)
```

```{r ar3-CptNonPar-testthat, include = FALSE}
testthat::expect_equal(CptNonPar_result, numeric(0))
testthat::expect_equal(CptNonPar_result, numeric(0), tolerance = 0.2)
```

```{r ar3-segmented}
Expand All @@ -787,7 +786,7 @@ testthat::expect_equal(CptNonPar_result, numeric(0))
```

```{r ar3-segmented-testthat, include = FALSE}
testthat::expect_equal(segmented_result, c(690))
testthat::expect_equal(segmented_result, c(690), tolerance = 0.2)
```

```{r ar3-mcp, eval = FALSE}
Expand All @@ -811,15 +810,15 @@ The true change point is 200.
```

```{r garch11-fastcpd-testthat, include = FALSE}
testthat::expect_equal(fastcpd_result, c(205))
testthat::expect_equal(fastcpd_result, c(205), tolerance = 0.2)
```

```{r garch11-CptNonPar}
(CptNonPar_result <- CptNonPar::np.mojo(garch_data, G = floor(length(garch_data) / 6))$cpts)
```

```{r garch11-CptNonPar-testthat, include = FALSE}
testthat::expect_equal(CptNonPar_result, c(206))
testthat::expect_equal(CptNonPar_result, c(206), tolerance = 0.2)
```

```{r garch11-strucchange, eval = FALSE}
Expand All @@ -838,15 +837,15 @@ The true change points is 500.
```

```{r var2-fastcpd-testthat, include = FALSE}
testthat::expect_equal(fastcpd_result, c(500))
testthat::expect_equal(fastcpd_result, c(500), tolerance = 0.2)
```

```{r var2-VARDetect}
(VARDetect_result <- VARDetect::tbss(var_data)$cp)
```

```{r var2-VARDetect-testthat, include = FALSE}
testthat::expect_equal(VARDetect_result, c(501))
testthat::expect_equal(VARDetect_result, c(501), tolerance = 0.2)
```

# Detection comparison using `well_log`
Expand Down Expand Up @@ -1020,6 +1019,12 @@ ggplot2::autoplot(microbenchmark_result)
- `bcp`: [[#5](https://github.com/doccstat/fastcpd/issues/5)].
- `gfpop`: [[#10](https://github.com/doccstat/fastcpd/issues/10)].

# Acknowledgements

- [Dr. Vito Muggeo](https://www.unipa.it/persone/docenti/m/vito.muggeo),
author of the `segmented` package for the tips about the piece-wise
constant function.

# Appendix: all code snippets

```{r ref.label = knitr::all_labels(), echo = TRUE, eval = FALSE}
Expand Down

0 comments on commit 6c6cb57

Please sign in to comment.