# NOT RUN {
## Examples below should take about 1-2 minutes.
## ------ (use simul_pois1) ------
# load simulated data set 'simul_pois1'
data(simul_pois1)
y <- simul_pois1$y
X <- as.matrix(simul_pois1[, -1])
# Bayesian variable selection for simulated data set
m1 <- poissonBvs(y = y, X = X)
# print, summarize and plot results
print(m1)
summary(m1)
plot(m1, maxPlots = 4)
plot(m1, burnin = FALSE, thin = FALSE, maxPlots = 4)
plot(m1, type = "acf")
# MCMC sampling without BVS with specific MCMC and prior settings
m2 <- poissonBvs(y = y, X = X, prior = list(slab = "Normal"),
mcmc = list(M = 6000, thin = 10), BVS = FALSE)
print(m2)
summary(m2, IAT = TRUE)
plot(m2)
# show traceplots disregarding thinning
plot(m2, thin = FALSE)
# specification of an overdispersed Poisson model with observation-specific
# (normal) random intercept
cID <- seq_along(y)
m3 <- poissonBvs(y = y, X = X, model = list(ri = TRUE, clusterID = cID))
# print, summarize and plot results
print(m3)
summary(m3)
# note that variance selection of the random intercept indicates that
# overdispersion is not present in the data
plot(m3, burnin = FALSE, thin = FALSE)
## ------ (use simul_pois2) ------
# load simulated data set 'simul_pois2'
data(simul_pois2)
y <- simul_pois2$y
X <- as.matrix(simul_pois2[, -c(1,2)])
cID <- simul_pois2$cID
# BVS for a Poisson model with cluster-specific random intercept
m4 <- poissonBvs(y = y, X = X, model = list(ri = TRUE, clusterID = cID),
mcmc = list(M = 4000, burnin = 2000))
print(m4)
summary(m4)
plot(m4)
# similar to m4, but without variance selection of the random intercept term
model <- list(gammafix = 1, ri = 1, clusterID = cID)
m5 <- poissonBvs(y = y, X = X, model = model, mcmc = list(M = 4000, thin = 5))
print(m5)
summary(m5)
plot(m5)
# MCMC sampling without BVS for clustered observations
m6 <- poissonBvs(y = y, X = X, model = list(ri = 1, clusterID = cID),
BVS = FALSE)
print(m6)
summary(m6)
plot(m6, maxPlots = 4)
# }
Run the code above in your browser using DataLab