Last data update: 2014.03.03

R: Approximate BCEE Implementation
ABCEER Documentation

Approximate BCEE Implementation

Description

A-BCEE implementation of the BCEE algorithm.

Usage

ABCEE(X, Y, U, omega, forX = NA, niter = 5000, nburn = 500, nthin = 10,
 maxmodelY = NA, OR = 20, family.X = "gaussian")

Arguments

X

A vector of observed values for the exposure.

Y

A vector of observed values for the continuous outcome.

U

A matrix of observed values for the M potential confounding covariates, where each column contains observed values for a potential confounding factor. A recommended implementation is to only consider pre-exposure covariates.

omega

The value of the hyperparameter omega in the BCEE's outcome model prior distribution. A recommended implementation is to take omega = sqrt(n)*c, where n is the sample size and c is a user-supplied constant value. Simulation studies suggest that values of c between 100 and 1000 yield good results.

forX

A Boolean vector of size M, where the mth element indicates whether or not the mth potential confounding covariate should be considered in the exposure modeling step of the BCEE algorithm. The default for forX is NA, which indicates that all potential confounding covariates should be considered in the exposure modeling step.

niter

The number of post burn-in iterations in the Markov chain Monte Carlo model composition (MC^3) algorithm (Madigan et al. 1995), prior to applying thinning. The default is 5000.

nburn

The number of burn-in iterations (prior to applying thinning). The default is 500.

nthin

The thinning of the chain. The default is 10.

maxmodelY

The maximum number of distinct outcome models that the algorithm can explore. Choosing a smaller value can shorten computing time. However, choosing a value that is too small will cause the algorithm to crash. The default is NA; the maximum number of outcome models that can be explored is then set to the minimum of niter + nburn and 2^M.

OR

A number specifying the maximum ratio for excluding models in Occam's window for the exposure modeling step (see the bic.glm help file, and Madigan & Raftery, 1994). The default is 20.

family.X

A description of the error distribution and link function to be used in the model. This can be a character string naming a family function, a family function or the result of a call to a family function. (See family for details of family functions.) The default is "gaussian"

Details

The ABCEE function first computes the exposure model's posterior distribution using the bic.glm function. The outcome model's posterior distribution is then computed using MC^3 (Madigan et al., 1995) as described in Talbot et al. (2015).

ABCEE assumes there are no missing values in the objects X, Y and U. The na.omit function which removes cases with missing data or an imputation package might be helpful.

Value

betas

A vector containing the sampled values for the exposure effect.

models.X

A matrix giving the posterior distribution of the exposure model. Each row corresponds to an exposure model. Within each row, the first M elements are Booleans indicating the inclusion (1) or the exclusion (0) of each potential confounding factor. The last element gives the posterior probability of the exposure model.

models.Y

A Boolean matrix identifying the sampled outcome models. Each row corresponds to a sampled outcome model. Within each row, the mth element equals 1 if and only if the mth potential confounding covariate is included in the sampled outcome model (and 0 otherwise).

Author(s)

Denis Talbot, Genevieve Lefebvre, Juli Atherton.

References

Madigan, D., York, J., Allard, D. (1995) Bayesian graphical models for discrete data, International Statistical Review, 63, 215-232.

Madigan, D., Raftery, A. E. (1994) Model selection and accounting for model uncertainty in graphical models using Occam's window, Journal of the American Statistical Association, 89 (428), 1535-1546.

Talbot, D., Lefebvre, G., Atherton, J. (2015) The Bayesian causal effect estimation algorithm, Journal of Causal Inference, 3(2), 207-236.

See Also

bic.glm, na.omit, NBCEE.

Examples

# In this example, U1 and U2 are potential confounding covariates
# generated as independent N(0,1).
# X is generated as a function of both U1 and U2 with a N(0,1) error.
# Y is generated as a function of X and U1 with a N(0,1) error.
# Variable U1 is the only confounder.
# The causal effect of X on Y equals 1. 
# The exposure effect estimator (beta hat) in the outcome model  
# including U1 and U2 or including U1 only is unbiased.
# The sample size is n = 200.

# Generating the data
set.seed(418949); 
U1 = rnorm(200); 
U2 = rnorm(200);
X = 0.5*U1 + 1*U2 + rnorm(200);
Y = 1*X + 0.5*U1 + rnorm(200);

# Using ABCEE to estimate the causal exposure effect
n = 200;
omega.c = 500;
results = ABCEE(X,Y,cbind(U1,U2), omega = omega.c*sqrt(n),
 niter = 1000, nthin = 5, nburn = 20);

# The posterior mean of the exposure effect:
mean(results$betas);
# The posterior standard deviation of the exposure effect:
sd(results$betas);
# The posterior distribution of the exposure model:
results$models.X;
# The posterior probability of inclusion of each covariate:
colMeans(results$models.Y);
# The posterior distribution of the outcome model:
table(apply(results$models.Y, 1, paste0, collapse = ""));

Results


R version 3.3.1 (2016-06-21) -- "Bug in Your Hair"
Copyright (C) 2016 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

> library(BCEE)
Loading required package: BMA
Loading required package: survival
Loading required package: leaps
Loading required package: robustbase

Attaching package: 'robustbase'

The following object is masked from 'package:survival':

    heart

Loading required package: inline
Loading required package: rrcov
Scalable Robust Estimators with High Breakdown Point (version 1.3-11)

> png(filename="/home/ddbj/snapshot/RGM3/R_CC/result/BCEE/ABCEE.Rd_%03d_medium.png", width=480, height=480)
> ### Name: ABCEE
> ### Title: Approximate BCEE Implementation
> ### Aliases: ABCEE
> ### Keywords: causal confounding model average
> 
> ### ** Examples
> 
> # In this example, U1 and U2 are potential confounding covariates
> # generated as independent N(0,1).
> # X is generated as a function of both U1 and U2 with a N(0,1) error.
> # Y is generated as a function of X and U1 with a N(0,1) error.
> # Variable U1 is the only confounder.
> # The causal effect of X on Y equals 1. 
> # The exposure effect estimator (beta hat) in the outcome model  
> # including U1 and U2 or including U1 only is unbiased.
> # The sample size is n = 200.
> 
> # Generating the data
> set.seed(418949); 
> U1 = rnorm(200); 
> U2 = rnorm(200);
> X = 0.5*U1 + 1*U2 + rnorm(200);
> Y = 1*X + 0.5*U1 + rnorm(200);
> 
> # Using ABCEE to estimate the causal exposure effect
> n = 200;
> omega.c = 500;
> results = ABCEE(X,Y,cbind(U1,U2), omega = omega.c*sqrt(n),
+  niter = 1000, nthin = 5, nburn = 20);
> 
> # The posterior mean of the exposure effect:
> mean(results$betas);
[1] 0.9615841
> # The posterior standard deviation of the exposure effect:
> sd(results$betas);
[1] 0.05521132
> # The posterior distribution of the exposure model:
> results$models.X;
     [,1] [,2] [,3]
[1,]    1    1    1
> # The posterior probability of inclusion of each covariate:
> colMeans(results$models.Y);
[1] 1.000 0.375
> # The posterior distribution of the outcome model:
> table(apply(results$models.Y, 1, paste0, collapse = ""));

 10  11 
125  75 
> 
> 
> 
> 
> 
> dev.off()
null device 
          1 
>