View source: R/fastcpd_wrappers.R
fastcpd_binomial | R Documentation |
fastcpd_binomial()
and fastcpd.binomial()
are
wrapper functions of fastcpd()
to find change points in
logistic 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_binomial(data, ...)
fastcpd.binomial(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 <- 500
p <- 4
x <- mvtnorm::rmvnorm(n, rep(0, p), diag(p))
theta <- rbind(rnorm(p, 0, 1), rnorm(p, 2, 1))
y <- c(
rbinom(300, 1, 1 / (1 + exp(-x[1:300, ] %*% theta[1, ]))),
rbinom(200, 1, 1 / (1 + exp(-x[301:n, ] %*% theta[2, ])))
)
result <- suppressWarnings(fastcpd.binomial(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.