Skip to content

Commit

Permalink
Update fastcpd.var example
Browse files Browse the repository at this point in the history
  • Loading branch information
doccstat committed Mar 19, 2024
1 parent b316126 commit 4d8908f
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 2 deletions.
8 changes: 8 additions & 0 deletions R/check.R
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,14 @@ get_beta <- function(beta, p, n, fastcpd_family, sigma_) {
}
}

get_convexity_coef <- function(convexity_coef, fastcpd_family) {
if (fastcpd_family == "mgaussian") {
-Inf
} else {
convexity_coef
}
}

get_p_response <- function(family, y, data) {
if (family %in% c(
"mean", "variance", "meanvariance", "mv", "ma", "arma", "arima", "garch"
Expand Down
1 change: 1 addition & 0 deletions R/fastcpd.R
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,7 @@ fastcpd <- function( # nolint: cyclomatic complexity
vanilla_percentage <-
get_vanilla_percentage(vanilla_percentage, cost, fastcpd_family)
beta <- get_beta(beta, p, nrow(data_), fastcpd_family, sigma_)
convexity_coef <- get_convexity_coef(convexity_coef, fastcpd_family)

result <- fastcpd_impl(
data_, beta, convexity_coef, cost_adjustment, segment_count, trim,
Expand Down
2 changes: 1 addition & 1 deletion man/fastcpd_var.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion tests/testthat/examples/fastcpd_var.R
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@ for (i in 1:200) {
for (i in 201:n) {
x[i + 2, ] <- theta_2 %*% c(x[i + 1, ], x[i, ]) + rnorm(p, 0, 1)
}
result <- fastcpd.var(x, 2, convexity_coef = -Inf)
result <- fastcpd.var(x, 2)
summary(result)

0 comments on commit 4d8908f

Please sign in to comment.