Description Usage Arguments Value Examples
This function estimates a model averaged double robust estimate.
1 2 |
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 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | 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
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.