diff --git a/R/check.R b/R/check.R index 236b156f..e6f2e475 100644 --- a/R/check.R +++ b/R/check.R @@ -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" diff --git a/R/fastcpd.R b/R/fastcpd.R index b26fb8c7..0dce5e04 100755 --- a/R/fastcpd.R +++ b/R/fastcpd.R @@ -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, diff --git a/man/fastcpd_var.Rd b/man/fastcpd_var.Rd index af158170..cb4293c4 100644 --- a/man/fastcpd_var.Rd +++ b/man/fastcpd_var.Rd @@ -40,6 +40,6 @@ 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) } diff --git a/tests/testthat/examples/fastcpd_var.R b/tests/testthat/examples/fastcpd_var.R index 6d982196..293ec097 100644 --- a/tests/testthat/examples/fastcpd_var.R +++ b/tests/testthat/examples/fastcpd_var.R @@ -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)