Title: | Model Averaged Double Robust Estimation |
---|---|
Description: | Estimates average treatment effects using model average double robust (MA-DR) estimation. The MA-DR estimator is defined as weighted average of double robust estimators, where each double robust estimator corresponds to a specific choice of the outcome model and the propensity score model. The MA-DR estimator extend the desirable double robustness property by achieving consistency under the much weaker assumption that either the true propensity score model or the true outcome model be within a specified, possibly large, class of models. |
Authors: | Matthew Cefalu |
Maintainer: | Matthew Cefalu <[email protected]> |
License: | GPL-3 |
Version: | 1.0.0 |
Built: | 2025-01-29 05:23:37 UTC |
Source: | https://github.com/cran/madr |
This function fits propensity score models and saves necessary information
add.to.dictionary(X, U, W, alpha)
add.to.dictionary(X, U, W, alpha)
X |
vector of the treatment (0/1) |
U |
matrix of covariates to be considered for inclusion/exclusion |
W |
matrix of covariates that will be included in all models (optional) |
alpha |
vector of inclusion indicators (which columns of U) to included in the propensity score model |
A list. The list contains the following named components:
out |
a list that contains the BIC and estimated propensity scores from propensity score models |
This function fits outcome models and saves necessary information
add.to.dictionary.outcome(Y, X, U, W, alpha, binary = F)
add.to.dictionary.outcome(Y, X, U, W, alpha, binary = F)
Y |
vector of the outcome |
X |
vector of the treatment (0/1) |
U |
matrix of covariates to be considered for inclusion/exclusion |
W |
matrix of covariates that will be included in all models (optional) |
alpha |
vector of inclusion indicators (which columns of U) to included in the propensity score model |
binary |
indicates if the outcome is binary |
A list. The list contains the following named components:
out |
a list that contains the BIC, predicted values, and estimated treatment effect from each outcome model |
This function transforms BIC to model probabilities
bic.to.prob(bic)
bic.to.prob(bic)
bic |
vector of BICs |
A vector of model probabilities of the same dimension of bic
This function transforms the input using the expit function
expit(x)
expit(x)
x |
vector of values to apply the expit function |
A vector of the same dimension of x
This function estimates a model averaged double robust estimate.
madr(Y, X, U, W = NULL, M = 1000, cut = 0.95, enumerate = F, tau = NULL, two.stage = NULL)
madr(Y, X, U, W = NULL, M = 1000, cut = 0.95, enumerate = F, tau = NULL, two.stage = NULL)
Y |
vector of the outcome |
X |
vector of the treatment (0/1) |
U |
matrix of covariates to be considered for inclusion/exclusion |
W |
matrix of covariates that will be included in all models (optional) |
M |
the number of MCMC iteration |
cut |
cumulative probability of models to be retained for improved computational efficiency (1 retains all visited models) |
enumerate |
indicator if all possible models should be enumerated (default: FALSE) |
tau |
scalar value for the prior model dependence (1 is an independent prior; defaults to 0) |
two.stage |
indicator if the two-stage procedure for calculating the model weights should be used (defaults to TRUE) |
A list. The list contains the following named components:
madr |
the model averaged double robust estimate |
weight.ps |
a vector that contains the inclusion probability of each covariate in the propensity score model |
weight.om |
a vector that contains the inclusion probability of each covariate in the outcome model |
set.seed(122) ## generate data n = 100 # number of observations k = 4 # number of covariates U = matrix(rnorm(n*k),n,k) colnames(U) = paste0("U",1:k) A = rbinom(n,1,expit(-1+.5*rowSums(U))) Y = rnorm(n,1+A+.25*rowSums(U)) ## A is confounded -- true effect is 1 lm(Y~A) ## fit ma-dr -- can enumerate models if k isnt too big res = madr(Y=Y,X=A,U=U,enumerate=TRUE,tau=1,two.stage=FALSE) # independent prior res res = madr(Y=Y,X=A,U=U,enumerate=TRUE,tau=0,two.stage=TRUE) # tau=0 and using two-stage weights res ## no need to refit madr each time when enumerating -- use summarize and specify different taus summary(res,tau=1,two.stage=FALSE) # independent prior summary(res,tau=0,two.stage=FALSE) summary(res,tau=0,two.stage=TRUE) # two-stage procedure for calculating weights ## use mcmc instead of enumerating (the default) madr(Y=Y,X=A,U=U,M=1000,cut=1) #should approximate tau=0 and two.stage=TRUE
set.seed(122) ## generate data n = 100 # number of observations k = 4 # number of covariates U = matrix(rnorm(n*k),n,k) colnames(U) = paste0("U",1:k) A = rbinom(n,1,expit(-1+.5*rowSums(U))) Y = rnorm(n,1+A+.25*rowSums(U)) ## A is confounded -- true effect is 1 lm(Y~A) ## fit ma-dr -- can enumerate models if k isnt too big res = madr(Y=Y,X=A,U=U,enumerate=TRUE,tau=1,two.stage=FALSE) # independent prior res res = madr(Y=Y,X=A,U=U,enumerate=TRUE,tau=0,two.stage=TRUE) # tau=0 and using two-stage weights res ## no need to refit madr each time when enumerating -- use summarize and specify different taus summary(res,tau=1,two.stage=FALSE) # independent prior summary(res,tau=0,two.stage=FALSE) summary(res,tau=0,two.stage=TRUE) # two-stage procedure for calculating weights ## use mcmc instead of enumerating (the default) madr(Y=Y,X=A,U=U,M=1000,cut=1) #should approximate tau=0 and two.stage=TRUE
This function enumerates all possible models and estimates a model averaged double robust estimate
madr.enumerate(Y, X, U, W = NULL, tau = 1, two.stage = F)
madr.enumerate(Y, X, U, W = NULL, tau = 1, two.stage = F)
Y |
vector of the outcome |
X |
vector of the treatment indicator (0/1) |
U |
matrix of covariates to be considered for inclusion/exclusion |
W |
matrix of covariates that will be included in all models (optional) |
tau |
scalar value for the prior model dependence (1 is an independent prior) |
two.stage |
indicator if the two-stage procedure for calculating the model weights should be used |
A object of class madr.enumerate. The object contains the following named components:
out |
a matrix that contains the BIC and estimated treatment from each outcome model |
ps |
a matrix that contains the BIC from each propensity score model |
dr |
a matrix that contains the model-specific double robust estimates |
U.names |
the column names of U |
This function uses a pseudo-MC3 algorithm to search the model space, then estimate a model averaged double robust estimate using the two-stage procedure for estimating model weights with tau=0.
madr.mcmc(Y, X, U, W = NULL, M = 1000, cut = 0.95)
madr.mcmc(Y, X, U, W = NULL, M = 1000, cut = 0.95)
Y |
vector of the outcome |
X |
vector of the treatment (0/1) |
U |
matrix of covariates to be considered for inclusion/exclusion |
W |
matrix of covariates that will be included in all models (optional) |
M |
the number of MCMC iteration |
cut |
cumulative probability of models to be retained for improved computational efficiency (1 retains all visited models) |
A list. The list contains the following named components:
madr |
the model averaged double robust estimate |
weight.ps |
a vector that contains the inclusion probability of each covariate in the propensity score model |
weight.om |
a vector that contains the inclusion probability of each covariate in the outcome model |
This function uses a pseudo-MC3 algorithm to search the outcome model space.
OM.MA(Y, X, U, W = NULL, M = 1000, alpha = NULL, binary = F)
OM.MA(Y, X, U, W = NULL, M = 1000, alpha = NULL, binary = F)
Y |
vector of the outcome |
X |
vector of the treatment (0/1) |
U |
matrix of covariates to be considered for inclusion/exclusion |
W |
matrix of covariates that will be included in all models (optional) |
M |
the number of MCMC iteration |
alpha |
vector of inclusion indicators (which columns of U) to start MCMC algorithm (optional) |
binary |
indicator if the outcome is binary (optional) |
A list. The list contains the following named components:
dict |
a list that contains the BIC, predicted values, and estimated treatment effect from each outcome model |
alpha |
the last model visited by the algorithm |
out.table |
a matrix that contains the BIC and estimated treatment effect from each outcome model |
This function enumerates and fits all possible outcome models
OM.MA.enumerate(Y, X, U, W = NULL)
OM.MA.enumerate(Y, X, U, W = NULL)
Y |
vector of the outcome |
X |
vector of the treatment indicator (0/1) |
U |
matrix of covariates to be considered for inclusion/exclusion |
W |
matrix of covariates that will be included in all models (optional) |
A list. The listcontains the following named components:
dict |
a list that contains the BIC, predicted values, and estimated treatment effect from each outcome model |
out.table |
a matrix that contains the BIC and estimated treatment effect from each outcome model |
This function prints results from madr.enumerate class
## S3 method for class 'madr.enumerate' print(x, ...)
## S3 method for class 'madr.enumerate' print(x, ...)
x |
madr.enumerate object |
... |
ignored |
This function prints results from madr.mcmc class
## S3 method for class 'madr.mcmc' print(x, ...)
## S3 method for class 'madr.mcmc' print(x, ...)
x |
madr.mcmc object |
... |
ignored |
This function prints results from summary.madr.enumerate class
## S3 method for class 'summary.madr.enumerate' print(x, ...)
## S3 method for class 'summary.madr.enumerate' print(x, ...)
x |
summary.madr.enumerate object |
... |
ignored |
This function uses a pseudo-MC3 algorithm to search the propensity score model space.
PS.MA(X, U, W = NULL, M = 1000, alpha = NULL, master.index = NULL, master.dict = list())
PS.MA(X, U, W = NULL, M = 1000, alpha = NULL, master.index = NULL, master.dict = list())
X |
vector of the treatment (0/1) |
U |
matrix of covariates to be considered for inclusion/exclusion |
W |
matrix of covariates that will be included in all models (optional) |
M |
the number of MCMC iteration |
alpha |
vector of inclusion indicators (which columns of U) to start MCMC algorithm (optional) |
master.index |
indexes which columns of U should be considered for inclusion in the propensity score model (optional) |
master.dict |
list containing information from previous propensity score model fits (optional) |
A list. The list contains the following named components:
dict |
a list that contains the BIC and estimated propensity scores from propensity score models |
alpha |
the last model visited by the algorithm |
out.table |
a matrix that contains the BIC from each propensity score model |
This function enumerates and fits all possible propensity score models
PS.MA.enumerate(X, U, W = NULL)
PS.MA.enumerate(X, U, W = NULL)
X |
vector of the treatment indicator (0/1) |
U |
matrix of covariates to be considered for inclusion/exclusion |
W |
matrix of covariates that will be included in all models (optional) |
A list. The list contains the following named components:
dict |
a list that contains the BIC and estimated propensity scores from propensity score models |
out.table |
a matrix that contains the BIC from each propensity score model |
This function estimates model averaged double robust estimate for different values of tau using a madr.enumerate object
## S3 method for class 'madr.enumerate' summary(object, tau = NULL, two.stage = NULL, ...)
## S3 method for class 'madr.enumerate' summary(object, tau = NULL, two.stage = NULL, ...)
object |
madr.enumerate object |
tau |
scalar value for the prior model dependence (1 is an independent prior; defaults to value used in madr.enumerate) |
two.stage |
indicator if the two-stage procedure for calculating the model weights should be used (defaults to value used in madr.enumerate) |
... |
ignored |
A list. The list contains the following named components:
madr |
the model averaged double robust estimate |
weight.ps |
a vector that contains the inclusion probability of each covariate in the propensity score model |
weight.om |
a vector that contains the inclusion probability of each covariate in the outcome model |
tau |
value of tau used in estimation |
two.stage |
indicator if the two-stage procedure for calculating the model weights was used |