{
data(CPP)
attach(CPP)
n <- NROW(CPP)
J <- H <- 10
premature <- as.numeric(gestage<=37)
mcmc <- list(nrep=5000, nb=2000, thin=5, ndisplay=4)
## too few iterations to be meaningful. see below for safer and more comprehensive results
mcmc <- list(nrep=10, nb=2, thin=1, ndisplay=4)
prior <- list(mu.theta=mean(gestage), k.theta=10, eta=rep(1, J)/J,
alpha=rep(1,H)/H, a=2, b=2, J=J, H=H)
fit.dummy <- comire.gibbs(gestage, dde, family="continuous",
mcmc=mcmc, prior=prior, seed=1, max.x=180)
summary(fit.dummy)
# \donttest{
## safer procedure with more iterations (it may take some time)
mcmc <- list(nrep=5000, nb=2000, thin=5, ndisplay=4)
## 1. binary case ##
prior <- list(pi0=mean(gestage), eta=rep(1, J)/J,
a.pi0=27, b.pi0=360, J=J)
fit_binary<- comire.gibbs(premature, dde, family="binary",
mcmc=mcmc, prior=prior, seed=5, max.x=180)
## 2. continuous case ##
prior <- list(mu.theta=mean(gestage), k.theta=10, eta=rep(1, J)/J,
alpha=rep(1,H)/H, a=2, b=2, J=J, H=H)
fit1 <- comire.gibbs(gestage, dde, family="continuous",
mcmc=mcmc, prior=prior, seed=5, max.x=180)
## 2.2 One confunder ##
mage_std <- scale(mage, center = TRUE, scale = TRUE)
prior <- list(mu.theta=mean(gestage), k.theta=10, mu.gamma=0, k.gamma=10,
eta=rep(1, J)/J, alpha=1/H, a=2, b=2, H=H, J=J)
fit2 <- comire.gibbs(gestage, dde, mage_std, family="continuous",
mcmc=mcmc, prior=prior, seed=5, max.x=180)
## 2.3 More confunders ##
Z <- cbind(mage, mbmi, sei)
Z <- scale(Z, center = TRUE, scale = TRUE)
Z <- as.matrix(cbind(Z, CPP$smoke))
colnames(Z) <- c("age", "BMI", "sei", "smoke")
mod <- lm(gestage ~ dde + Z)
prior <- list(mu.theta = mod$coefficients[1], k.theta = 10,
mu.gamma = mod$coefficients[-c(1, 2)], sigma.gamma = diag(rep(10, 4)),
eta = rep(1, J)/J, alpha = 1/H, a = 2, b = 2, H = H, J = J)
fit3 <- comire.gibbs(y = gestage, x = dde, z = Z, family = "continuous", mcmc = mcmc,
prior = prior, seed = 5)
# }
}
Run the code above in your browser using DataLab