Title: | Convex Mixture Regression |
---|---|
Description: | Posterior inference under the convex mixture regression (CoMiRe) models introduced by Canale, Durante, and Dunson (2018) <doi:10.1111/biom.12917>. |
Authors: | Antonio Canale [aut, cre], Daniele Durante [ctb], Arianna Falcioni [aut], Luisa Galtarossa [aut], Tommaso Rigon [ctb] |
Maintainer: | Antonio Canale <[email protected]> |
License: | GPL-2 |
Version: | 0.8 |
Built: | 2024-12-15 07:38:23 UTC |
Source: | CRAN |
Posterior inference under the convex mixture regression (CoMiRe) models introduced by Canale, Durante, and Dunson (2018) <doi:10.1111/biom.12917>.
The CoMiRe
package implements the convex mixture regresion approach of Canale, Durante, and Dunson (2018) and some extensions to deal with binary response variables or to account for the presence of continuous and categorical confunders. Estimation is conducted via Gibbs sampler. Posterior plots for inference and goodness-of-fit tests are also available.
Antonio Canale [aut, cre], Daniele Durante [ctb], Arianna Falcioni [aut], Luisa Galtarossa [aut], Tommaso Rigon [ctb] Maintainer: Antonio Canale <[email protected]>
Canale, A., Durante, D., and Dunson, D. (2018), Convex Mixture Regression for Quantitative Risk Assessment, Biometrics, 74, 1331-1340
Additional risk function estimated from the object fit
add.risk(y, x, fit, mcmc, a, alpha=0.05, x.grid=NULL, y.grid=NULL)
add.risk(y, x, fit, mcmc, a, alpha=0.05, x.grid=NULL, y.grid=NULL)
y |
optional numeric vector for the response used in |
x |
numeric vector for the covariate relative to the dose of exposure used in |
fit |
the output of |
mcmc |
a list giving the MCMC parameters. |
a |
threshold of clinical interest for the response variable |
alpha |
level of the credible bands. |
x.grid |
optional numerical vector giving the actual values of the grid for x for plotting the additional risk function. If |
y.grid |
optional numerical vector giving the actual values of the grid for y for plotting the additional risk function. If |
A list of arguments for generating posterior output. It contains:
mcmc.risk
a matrix containing in the lines the MCMC chains, after thinning, of the additional risk function over x.grid
, in the columns.
summary.risk
a data frame with four variables: the posterior means of the additional risk function over x.grid
, the respective and
quantiles, and
x.grid
.
Antonio Canale, Arianna Falcioni
{ 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) risk.data <- add.risk(y = gestage, x = dde, fit = fit.dummy, mcmc = mcmc, a = 37, x.grid = seq(0, max(dde), length = 100)) riskplot(risk.data$summary.risk, xlab="DDE", x = dde, xlim = c(0,150)) ## safer procedure with more iterations (it may take some time) mcmc <- list(nrep=5000, nb=2000, thin=5, ndisplay=4) ## Fit the model for continuous y 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) risk.data <- add.risk(y = gestage, x = dde, fit = fit1, mcmc = mcmc, a = 37, x.grid = seq(0, max(dde), length = 100)) riskplot(risk.data$summary.risk, xlab="DDE", x = dde, xlim = c(0,150)) }
{ 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) risk.data <- add.risk(y = gestage, x = dde, fit = fit.dummy, mcmc = mcmc, a = 37, x.grid = seq(0, max(dde), length = 100)) riskplot(risk.data$summary.risk, xlab="DDE", x = dde, xlim = c(0,150)) ## safer procedure with more iterations (it may take some time) mcmc <- list(nrep=5000, nb=2000, thin=5, ndisplay=4) ## Fit the model for continuous y 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) risk.data <- add.risk(y = gestage, x = dde, fit = fit1, mcmc = mcmc, a = 37, x.grid = seq(0, max(dde), length = 100)) riskplot(risk.data$summary.risk, xlab="DDE", x = dde, xlim = c(0,150)) }
A constructor for the classCoMiRe
class. The class classCoMiRe
is a named list containing
the output of the posterior estimation of CoMiRe model implemented in comire.gibbs
as.classCoMiRe(call = NULL, out = NULL, z = NULL, z.val = NULL, f0 = NULL, f1 = NULL, nrep, nb, bin = FALSE, univariate = TRUE)
as.classCoMiRe(call = NULL, out = NULL, z = NULL, z.val = NULL, f0 = NULL, f1 = NULL, nrep, nb, bin = FALSE, univariate = TRUE)
call |
a formula for |
out |
an output of |
z |
optional numeric vector or matrix for the confounding covariates. |
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 |
f0 , f1
|
optional matrices containing simulated values of the mixture densities at low and high dose exposure; default values are simulated with |
nrep |
integer giving the total number of iterations used in |
nb |
integer giving the number of burn-in iterations used in |
bin |
logical. It is |
univariate |
logical. It is |
Antonio Canale, Arianna Falcioni
plotPosterior mean (continuous lines) and pointwise credible bands (shaded areas) for .
betaplot(x, fit, x.grid = NULL, xlim = c(0, max(x)), xlab = "x")
betaplot(x, fit, x.grid = NULL, xlim = c(0, max(x)), xlab = "x")
x |
numeric vector for the covariate relative to the dose of exposure used in |
fit |
the output of |
x.grid |
optional numerical vector giving the actual values of the grid for x for plotting |
xlim |
numeric vectors of length 2, giving the x coordinates ranges for the plot. |
xlab |
the title of the x axis. |
Antonio Canale
{ 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) betaplot(x=dde, fit=fit.dummy, x.grid=seq(0,180, length=100), xlim=c(0,150)) ## safer procedure with more iterations (it may take some time) mcmc <- list(nrep=5000, nb=2000, thin=5, ndisplay=4) ## Fit the model for continuous y 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) betaplot(x=dde, fit=fit1, x.grid=seq(0,180, length=100), xlim=c(0,150)) }
{ 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) betaplot(x=dde, fit=fit.dummy, x.grid=seq(0,180, length=100), xlim=c(0,150)) ## safer procedure with more iterations (it may take some time) mcmc <- list(nrep=5000, nb=2000, thin=5, ndisplay=4) ## Fit the model for continuous y 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) betaplot(x=dde, fit=fit1, x.grid=seq(0,180, length=100), xlim=c(0,150)) }
Benchmark dose associated to a particular risk
BMD(level, risk, x, alpha=0.05)
BMD(level, risk, x, alpha=0.05)
level |
dose level of interest. |
risk |
|
x |
numeric vector for the covariate relative to the dose of exposure used in |
alpha |
level of the credible bands. |
A dataframe containing as variables:
q
the dose level of interest.
BMD
the benchmark dose.
low
lower credible limit.
upp
upper credible limit.
BMDL
a more conservative benchmark dose.
Antonio Canale
{ 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) risk.data <- add.risk(y = gestage, x = dde, fit = fit.dummy, mcmc = mcmc, a = 37, x.grid = seq(0, max(dde), length = 100)) bmd.data <- BMD(seq(0,.20, length=50), risk.data$mcmc.risk, x=seq(0,max(dde), length=100), alpha=0.05) bmd.plot(bmd.data) ## safer procedure with more iterations (it may take some time) mcmc <- list(nrep=5000, nb=2000, thin=5, ndisplay=4) ## Fit the model for continuous y 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 <- comire.gibbs(gestage, dde, family="continuous", mcmc=mcmc, prior=prior, seed=5, max.x=180) risk.data <- add.risk(y = gestage, x = dde, fit = fit, mcmc = mcmc, a = 37, x.grid = seq(0, max(dde), length = 100)) bmd.data <- BMD(seq(0,.20, length=50), risk.data$mcmc.risk, x=seq(0,max(dde), length=100), alpha=0.05) bmd.plot(bmd.data) }
{ 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) risk.data <- add.risk(y = gestage, x = dde, fit = fit.dummy, mcmc = mcmc, a = 37, x.grid = seq(0, max(dde), length = 100)) bmd.data <- BMD(seq(0,.20, length=50), risk.data$mcmc.risk, x=seq(0,max(dde), length=100), alpha=0.05) bmd.plot(bmd.data) ## safer procedure with more iterations (it may take some time) mcmc <- list(nrep=5000, nb=2000, thin=5, ndisplay=4) ## Fit the model for continuous y 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 <- comire.gibbs(gestage, dde, family="continuous", mcmc=mcmc, prior=prior, seed=5, max.x=180) risk.data <- add.risk(y = gestage, x = dde, fit = fit, mcmc = mcmc, a = 37, x.grid = seq(0, max(dde), length = 100)) bmd.data <- BMD(seq(0,.20, length=50), risk.data$mcmc.risk, x=seq(0,max(dde), length=100), alpha=0.05) bmd.plot(bmd.data) }
Posterior mean (continuous lines) and pointwise credible bands (shaded areas) for the benchmark dose in function of the increase in risk.
bmd.plot(bmd.data)
bmd.plot(bmd.data)
bmd.data |
output of |
Antonio Canale
{ 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) risk.data <- add.risk(y = gestage, x = dde, fit = fit.dummy, mcmc = mcmc, a = 37, x.grid = seq(0, max(dde), length = 100)) bmd.data <- BMD(seq(0,.20, length=50), risk.data$mcmc.risk, x=seq(0,max(dde), length=100), alpha=0.05) bmd.plot(bmd.data) ## safer procedure with more iterations (it may take some time) mcmc <- list(nrep=5000, nb=2000, thin=5, ndisplay=4) ## Fit the model for continuous y 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 <- comire.gibbs(gestage, dde, family="continuous", mcmc=mcmc, prior=prior, seed=5, max.x=180) risk.data <- add.risk(y = gestage, x = dde, fit = fit, mcmc = mcmc, a = 37, x.grid = seq(0, max(dde), length = 100)) bmd.data <- BMD(seq(0,.20, length=50), risk.data$mcmc.risk, x=seq(0,max(dde), length=100), alpha=0.05) bmd.plot(bmd.data) }
{ 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) risk.data <- add.risk(y = gestage, x = dde, fit = fit.dummy, mcmc = mcmc, a = 37, x.grid = seq(0, max(dde), length = 100)) bmd.data <- BMD(seq(0,.20, length=50), risk.data$mcmc.risk, x=seq(0,max(dde), length=100), alpha=0.05) bmd.plot(bmd.data) ## safer procedure with more iterations (it may take some time) mcmc <- list(nrep=5000, nb=2000, thin=5, ndisplay=4) ## Fit the model for continuous y 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 <- comire.gibbs(gestage, dde, family="continuous", mcmc=mcmc, prior=prior, seed=5, max.x=180) risk.data <- add.risk(y = gestage, x = dde, fit = fit, mcmc = mcmc, a = 37, x.grid = seq(0, max(dde), length = 100)) bmd.data <- BMD(seq(0,.20, length=50), risk.data$mcmc.risk, x=seq(0,max(dde), length=100), alpha=0.05) bmd.plot(bmd.data) }
Posterior inference via Gibbs sampler for CoMiRe model
comire.gibbs(y, x, z = NULL, family = 'continuous', grid = NULL, mcmc, prior, state = NULL, seed, max.x = max(x), z.val = NULL, verbose = TRUE)
comire.gibbs(y, x, z = NULL, family = 'continuous', grid = NULL, mcmc, prior, state = NULL, seed, max.x = max(x), z.val = NULL, verbose = TRUE)
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 |
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
.
An object of the class classCoMiRe
, i.e. a list of arguments for generating posterior output. It contains:
call
the model formula
post.means
a list containing the posterior mean density beta over the grid, of all the mixture parameters and,
if family = "continuous"
and z = NULL
, of and
over the
y.grid
.
ci
a list containing the 95% credible intervals for all the quantities stored in post.means
.
mcmc
a list containing all the MCMC chains.
z
the same of the input
z.val
the same of the input
f0,f1
MCMC replicates of the density in the two extremes (only if family = 'continuous'
)
nrep,nb
the same values of the list mcmc
in the input arguments
bin
logical, equal to TRUE
if family = 'binary'
univariate
logical, equal to TRUE
if z
is null or a vector
Antonio Canale [aut, cre], Daniele Durante [ctb], Arianna Falcioni [aut], Luisa Galtarossa [aut], Tommaso Rigon [ctb]
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
{ 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) }
{ 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) }
Pointwise posterior mean (continuous blue lines), and credible bands (shaded blue areas) for f (y | x, z)
calculated in x.val
under the the model fitted in fit
.
fit.pdf.mcmc(y, x, fit, mcmc, J=10, H = 10, alpha = 0.05, max.x = max(x), x.val, y.grid = NULL, xlim = c(0, max(x)), ylim = c(0, 1), xlab = NULL)
fit.pdf.mcmc(y, x, fit, mcmc, J=10, H = 10, alpha = 0.05, max.x = max(x), x.val, y.grid = NULL, xlim = c(0, max(x)), ylim = c(0, 1), xlab = NULL)
y |
optional numeric vector for the response used in |
x |
numeric vector for the covariate relative to the dose of exposure used in |
fit |
the output of |
mcmc |
a list giving the MCMC parameters. |
J |
parameter controlling the number of elements of the I-spline basis |
H |
total number of components in the mixture at |
alpha |
level of the credible bands. |
max.x |
maximum value allowed for x. |
x.val |
central points of each dose interval to be used in the posterior estimation of the probability density function. |
y.grid |
optional numerical vector giving the actual values of the grid for y for plotting the posterior mean density. If |
xlim , ylim
|
numeric vectors of length 2, giving the x and y coordinates ranges for the plot. |
xlab |
the title of the x axis. |
Antonio Canale, Arianna Falcioni
{ 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) fit.pdf.mcmc(y = gestage, x = dde, fit = fit.dummy, mcmc = mcmc, J = 10, H = 10, alpha = 0.05, max.x = max(dde), x.val = 125, xlim = c(25,48), ylim = c(0,0.25), xlab = "Gest. age. for DDE = 125") ## safer procedure with more iterations (it may take some time) mcmc <- list(nrep=5000, nb=2000, thin=5, ndisplay=4) ## Fit the model for continuous y 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) fit.pdf.mcmc(y = gestage, x = dde, fit = fit1, mcmc = mcmc, J = 10, H = 10, alpha = 0.05, max.x = max(dde), x.val = 125, xlim = c(25,48), ylim = c(0,0.25), xlab = "Gest. age. for DDE = 125") }
{ 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) fit.pdf.mcmc(y = gestage, x = dde, fit = fit.dummy, mcmc = mcmc, J = 10, H = 10, alpha = 0.05, max.x = max(dde), x.val = 125, xlim = c(25,48), ylim = c(0,0.25), xlab = "Gest. age. for DDE = 125") ## safer procedure with more iterations (it may take some time) mcmc <- list(nrep=5000, nb=2000, thin=5, ndisplay=4) ## Fit the model for continuous y 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) fit.pdf.mcmc(y = gestage, x = dde, fit = fit1, mcmc = mcmc, J = 10, H = 10, alpha = 0.05, max.x = max(dde), x.val = 125, xlim = c(25,48), ylim = c(0,0.25), xlab = "Gest. age. for DDE = 125") }
An S3 plot method for an object of classCoMiRe
class.
## S3 method for class 'classCoMiRe' plot( x, y, xobs, mcmc, J = 10, H = 10, a = NULL, max.x = max(xobs), bandwidth = 20, x.grid = NULL, xlim = c(0, max(xobs)), ylim = c(0, 1), xlab = "x", alpha = 0.05, risk = TRUE, bmd = TRUE, level, oneevery = 20, ... )
## S3 method for class 'classCoMiRe' plot( x, y, xobs, mcmc, J = 10, H = 10, a = NULL, max.x = max(xobs), bandwidth = 20, x.grid = NULL, xlim = c(0, max(xobs)), ylim = c(0, 1), xlab = "x", alpha = 0.05, risk = TRUE, bmd = TRUE, level, oneevery = 20, ... )
x |
the output of |
y |
numeric vector for the response used in |
xobs |
numeric vector for the covariate relative to the dose of exposure used in |
mcmc |
a list giving the MCMC parameters. |
J |
parameter controlling the number of elements of the I-spline basis |
H |
total number of components in the mixture at |
a |
optional threshold of clinical interest for the response variable. |
max.x |
maximum value allowed for x. |
bandwidth |
the kernel bandwidth smoothing parameter for the |
x.grid |
optional numerical vector giving the actual values of the grid for x for plotting the additional risk function. If |
xlim , ylim
|
numeric vectors of length 2, giving the x and y coordinates ranges for the plot. |
xlab |
the title of the x axis. |
alpha |
level of the credible bands, default 0.05 |
risk |
if |
bmd |
if |
level |
if |
oneevery |
integer number representing how many MCMC draws to plot in the posterior predictive check. It draws one sample every |
... |
additional arguments to be passed. |
The output is a list of
ggplot2
plots containing the result of the betaplot
function and, if the threshold a
is provided, of
post.pred.check
, riskplot
, bmd.plot
.
If a=NULL
returns only betaplot
otherwise, if risk=FALSE
and
bmd=FALSE
returns a list containing betaplot
(which is automatically plotted)
and post.pred.check
plot. Finally, if a
is provided, risk=TRUE
and bmd=TRUE
returns a list with betaplot
, post.pred.check
, riskplot
and bmd.plot
.
Antonio Canale, Arianna Falcioni
A plot for an object of classCoMiRe
class. The plot is a goodness-of-fit assessment of CoMiRe model.
Since Version 0.8 if z
is provided into the fit
object, an error message is returned.
If family = 'continuous'
, a smoothed empirical estimate of F(a|x) = pr(y < a | x) is computed from the observed data (black line)
and from some of the data sets simulated from the posterior predictive distribution in the fit
object (grey lines).
If family = 'binary'
, a smoothed empirical estimate of the proportion of events (black line) and of the smoothed empirical
proportion of data simulated from the posterior predictive distribution in the fit
object (grey lines).
In the x axis are reported the observed exposures.
post.pred.check(y, x, fit, mcmc, J=10, H=10, a, max.x=max(x), xlim=c(0, max(x)), bandwidth = 20, oneevery = 20)
post.pred.check(y, x, fit, mcmc, J=10, H=10, a, max.x=max(x), xlim=c(0, max(x)), bandwidth = 20, oneevery = 20)
y |
numeric vector for the response used in |
x |
numeric vector for the covariate relative to the dose of exposure used in |
fit |
the output of |
mcmc |
a list giving the MCMC parameters |
J |
parameter controlling the number of elements of the I-spline basis |
H |
total number of components in the mixture at |
a |
threshold of clinical interest to compute the F(a|x,z) |
max.x |
maximum value allowed for x |
xlim |
numeric vectors of length 2, giving the x coordinates ranges for the plot |
bandwidth |
the kernel bandwidth smoothing parameter |
oneevery |
integer number representing how many MCMC draws to plot in the posterior predictive check. It draws one sample every |
Antonio Canale, Arianna Falcioni
{ 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) post.pred.check(y = gestage, x = dde, fit = fit.dummy, mcmc = mcmc, J = 10, H = 10, a = 37, max.x = max(dde), xlim = c(0,150), oneevery = 4) ## safer procedure with more iterations (it may take some time) mcmc <- list(nrep=5000, nb=2000, thin=5, ndisplay=4) ## Fit the model for continuous y 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) post.pred.check(y = gestage, x = dde, fit = fit1, mcmc = mcmc, J = 10, H = 10, a = 37, max.x = max(dde), xlim = c(0,150)) }
{ 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) post.pred.check(y = gestage, x = dde, fit = fit.dummy, mcmc = mcmc, J = 10, H = 10, a = 37, max.x = max(dde), xlim = c(0,150), oneevery = 4) ## safer procedure with more iterations (it may take some time) mcmc <- list(nrep=5000, nb=2000, thin=5, ndisplay=4) ## Fit the model for continuous y 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) post.pred.check(y = gestage, x = dde, fit = fit1, mcmc = mcmc, J = 10, H = 10, a = 37, max.x = max(dde), xlim = c(0,150)) }
This function computes the predicted values of the density al low
dose f_0
and of the density at high dose f_{inf}
, for fixed values
of the confounders z
.
predict_new_z(fit, y, z.val)
predict_new_z(fit, y, z.val)
fit |
the output of |
y |
numeric vector for the response used in |
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 |
An object of class classCoMiRe
.
Antonio Canale, Arianna Falcioni
The print.classCoMiRe
method prints the type of a classCoMiRe
object.
## S3 method for class 'classCoMiRe' print(x, ...)
## S3 method for class 'classCoMiRe' print(x, ...)
x |
an object of class |
... |
additional arguments. |
Antonio Canale, Arianna Falcioni
Posterior mean (continuous lines) and pointwise credible bands (shaded areas) for .
riskplot(risk.data, xlab = NULL, x = NULL, ylim=c(0,1), xlim=c(0, max(x)))
riskplot(risk.data, xlab = NULL, x = NULL, ylim=c(0,1), xlim=c(0, max(x)))
risk.data |
output of |
xlab |
the title of the x axis. |
x |
numeric vector for the covariate relative to the dose of exposure used in |
xlim , ylim
|
numeric vectors of length 2, giving the x and y coordinates ranges for the plot. |
Antonio Canale
{ 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) risk.data <- add.risk(y = gestage, x = dde, fit = fit.dummy, mcmc = mcmc, a = 37, x.grid = seq(0, max(dde), length = 100)) riskplot(risk.data$summary.risk, xlab="DDE", x = dde, xlim = c(0,150)) ## safer procedure with more iterations (it may take some time) mcmc <- list(nrep=5000, nb=2000, thin=5, ndisplay=4) ## Fit the model for continuous y 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 <- comire.gibbs(gestage, dde, family="continuous", mcmc=mcmc, prior=prior, seed=5, max.x=180) risk.data <- add.risk(y = gestage, x = dde, fit = fit, mcmc = mcmc, a = 37, x.grid = seq(0, max(dde), length = 100)) riskplot(risk.data$summary.risk, xlab="DDE", x = dde, xlim = c(0,150)) }
{ 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) risk.data <- add.risk(y = gestage, x = dde, fit = fit.dummy, mcmc = mcmc, a = 37, x.grid = seq(0, max(dde), length = 100)) riskplot(risk.data$summary.risk, xlab="DDE", x = dde, xlim = c(0,150)) ## safer procedure with more iterations (it may take some time) mcmc <- list(nrep=5000, nb=2000, thin=5, ndisplay=4) ## Fit the model for continuous y 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 <- comire.gibbs(gestage, dde, family="continuous", mcmc=mcmc, prior=prior, seed=5, max.x=180) risk.data <- add.risk(y = gestage, x = dde, fit = fit, mcmc = mcmc, a = 37, x.grid = seq(0, max(dde), length = 100)) riskplot(risk.data$summary.risk, xlab="DDE", x = dde, xlim = c(0,150)) }
The summary.classCoMiRe
method provides summary information on classCoMiRe
objects.
## S3 method for class 'classCoMiRe' summary(object, ...)
## S3 method for class 'classCoMiRe' summary(object, ...)
object |
an object of class |
... |
additional arguments |
Antonio Canale Arianna Falcioni