Skip to contents

fastcpd_poisson() and fastcpd.poisson() are wrapper functions of fastcpd() to find change points in Poisson regression models. The function is similar to fastcpd() except that the data is by default a matrix or data frame with the response variable as the first column and thus a formula is not required here.

Usage

fastcpd_poisson(data, ...)

fastcpd.poisson(data, ...)

Arguments

data

A matrix or a data frame with the response variable as the first column.

...

Other arguments passed to fastcpd(), for example, segment_count.

Value

A fastcpd object.

See also

Examples

# \donttest{
if (requireNamespace("mvtnorm", quietly = TRUE)) {
  set.seed(1)
  n <- 1100
  p <- 3
  x <- mvtnorm::rmvnorm(n, rep(0, p), diag(p))
  delta <- rnorm(p)
  theta_0 <- c(1, 0.3, -1)
  y <- c(
    rpois(500, exp(x[1:500, ] %*% theta_0)),
    rpois(300, exp(x[501:800, ] %*% (theta_0 + delta))),
    rpois(200, exp(x[801:1000, ] %*% theta_0)),
    rpois(100, exp(x[1001:1100, ] %*% (theta_0 - delta)))
  )
  result <- fastcpd.poisson(cbind(y, x))
  summary(result)
  plot(result)
}
#> 
#> Call:
#> fastcpd.poisson(data = cbind(y, x))
#> 
#> Change points:
#> 498 805 1003 
#> 
#> Cost values:
#> 230.0866 190.1381 82.77324 38.45199 
#> 
#> Parameters:
#>   segment 1  segment 2  segment 3  segment 4
#> 1  1.020002  0.6391880  1.0424108  1.4451928
#> 2  0.275458 -0.2585056  0.2620085  0.9910079
#> 3 -1.048875 -0.5768481 -0.9632918 -1.4354638

# }