comire.gibbs {CoMiRe} | R Documentation |
Gibbs sampler for CoMiRe model
Description
Posterior inference via Gibbs sampler for CoMiRe model
Usage
comire.gibbs(y, x, z = NULL, family = 'continuous',
grid = NULL, mcmc, prior,
state = NULL, seed, max.x = max(x), z.val = NULL, verbose = TRUE)
Arguments
y |
numeric vector for the response:
when |
x |
numeric vector for the covariate relative to the dose of exposure. |
z |
numeric vector for the confunders; a vector if there is only one confounder or a matrix for two or more confunders |
family |
type of |
grid |
a list giving the parameters for plotting the posterior mean density and the posterior mean
|
mcmc |
a list giving the MCMC parameters. It must include the following integers: |
prior |
a list containing the values of the hyperparameters. If
If
|
state |
if |
seed |
seed for random initialization. |
max.x |
maximum value allowed for |
z.val |
optional numeric vector containing a fixed value of interest for each of the confounding covariates to be used for the plots. Default value is |
verbose |
logical, if |
Details
The function fit a convex mixture regression (CoMiRe
) model (Canale, Durante, Dunson, 2018) via Gibbs sampler.
For continuous outcome , adverse esposure level
and no confunding
variables, one can set
family = 'continuous'
and z = NULL
and fit model
;
where
is a a monotone nondecreasing interpolation function, constrained between 0 and 1 and
are monotone nondecreasing I-splines basis.
If confounding covariates
are available, passing the argument
z
the function fits model
;
where:
, and
.
Finally, if is a binary response, one can set
family = 'binary'
and fit model
;
where is
.
Value
An object of the class classCoMiRe
, i.e. a list of arguments for generating posterior output. It contains:
call
the model formulapost.means
a list containing the posterior mean density beta over the grid, of all the mixture parameters and, iffamily = "continuous"
andz = NULL
, ofand
over the
y.grid
.ci
a list containing the 95% credible intervals for all the quantities stored inpost.means
.mcmc
a list containing all the MCMC chains.z
the same of the inputz.val
the same of the inputf0,f1
MCMC replicates of the density in the two extremes (only iffamily = 'continuous'
)nrep,nb
the same values of the listmcmc
in the input argumentsbin
logical, equal toTRUE
iffamily = 'binary'
univariate
logical, equal toTRUE
ifz
is null or a vector
Author(s)
Antonio Canale [aut, cre], Daniele Durante [ctb], Arianna Falcioni [aut], Luisa Galtarossa [aut], Tommaso Rigon [ctb]
References
Canale, A., Durante, D., and Dunson, D. (2018), Convex Mixture Regression for Quantitative Risk Assessment, Biometrics, 74, 1331-1340
Galtarossa, L., Canale, A., (2019), A Convex Mixture Model for Binomial Regression, Book of Short Papers SIS 2019
Examples
{
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)
## 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)
}