if (FALSE) {
n <- 150
reg <- 3
true.s <- gl(reg, n/reg, n)
rho.true <- c(1.5, 0.5, 3)
b0.true <- c(1, 3, 1)
b1.true <- c(1, -2, 2)
x1 <- runif(n, 0, 2)
nu.true <- rgamma(n, rho.true[true.s], rho.true[true.s])
mu <- nu.true * exp(b0.true[true.s] + x1 * b1.true[true.s])
y <- rpois(n, mu)
posterior <- MCMCnegbinChange(y ~ x1, m = 2, verbose = 1000,
marginal.likelihood = "Chib95",
e = 2, f = 2, g = 10,
b0 = rep(0, 2), B0 = (1/9) * diag(2),
rho.step = rep(0.75, times = 3),
seed = list(NA, 2))
par(mfrow=c(attr(posterior, "m") + 1, 1), mai=c(0.4, 0.6, 0.3, 0.05))
plotState(posterior, legend.control = c(1, 0.6))
plotChangepoint(posterior, verbose = TRUE, ylab="Density",
start=1, overlay=TRUE)
open.ended <- MCMCnegbinChange(y ~ x1, m = 10, verbose = 1000,
fixed.m = FALSE, mcmc = 2000, burnin = 2000,
e = 2, f = 2, g = 10,
a = 100, b = 1,
b0 = rep(0, 2), B0 = (1/9) * diag(2),
rho.step = 0.75,
seed = list(NA, 2))
plotState(open.ended, legend.control = c(1, 0.6))
}
Run the code above in your browser using DataLab