View source: R/fastcpd_wrappers.R
fastcpd_poisson | R Documentation |
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.
fastcpd_poisson(data, ...)
fastcpd.poisson(data, ...)
data |
A matrix or a data frame with the response variable as the first column. |
... |
Other arguments passed to |
A fastcpd object.
fastcpd()
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)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.