Description Usage Arguments Details Value Examples
dsmatchQTE
applys matching algorithm to estimate quantile
treatment effect based on propensity score and prognostic score.
Classical matching algortihms, including propensity score matching,
prognositc score matching and matching directly on covarites are
also contained for comparison. Covariate balance results are also
provided.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | dsmatchQTE(
Y,
X,
A,
p,
method = "dsm",
model.ps = "other",
ps = NULL,
lp.ps = NULL,
model.pg = "other",
pg = NULL,
lp.pg = NULL,
cov.balance = F,
varest = F,
boots = 100,
mc = F,
ncpus = 4
)
|
Y |
Outcome as numeric vector. |
X |
Covarites as numeric vector or matrix. |
A |
Treatment assignment as numeric vector with |
p |
Quantile to be estimated. Must be a numeric scalar between 0 and 1. |
method |
Matching method to use, including |
model.ps |
Fitted model for propensity score, including
|
ps |
Propensity score as numeric vector given by user. Don't need
to be specified if |
lp.ps |
Linear predictors for propensity score as numeric vector or
matrix. Don't need to be specified if |
model.pg |
Fitted model for prognostic score, including
|
pg |
Prognostic score as numeric matrix given by user. The first
column is potential outcome for control group and the second column is
potential outcome for treatment group. Don't need to be specified if
|
lp.pg |
Linear predictors for prognostic score as numeric vector or
matrix. Don't need to be specified if |
cov.balance |
A logical scalar for whether covariance balance results should be shown. |
varest |
A logical scalar for whether variance of estimator should be estimated. |
boots |
A numeric scalar for number of bootstrap relicates in
variance estimation. Don't need to be specified if |
mc |
A logical scalar for whether multiple cores are used in
variance estimation. Don't need to be specified if |
ncpus |
A numeric scalar for number of cores used in
variance estimation. Don't need to be specified if |
For both propensity socre and prognostic score, user should either
select a model or provide the score directly. If linear predictors
are used to fit a logistic model for propensity score or a linear
model for prognostic score, they should be determined by
lp.ps
or lp.pg
argument. If model.ps
(and
lp.ps
if linear predictors are used) is given, then
ps
does not need to be specified, and vice versa. However,
if propensity socre is given by ps
while model.ps
is chosen at the same time, the model will be ignored and matching
will be based on the score given by the user directly. A warning
will be thrown if this situation happens. Similar results for
prognostic score.
A special model for prognostic score is the zero inflated regression model, which fits a logistic model for the probability to be zero, and a regression model for the non-zero values.
Results are put in a list:
est.ds |
Point estimate of ATE if matching is based on double score |
est.ps |
Point estimate of ATE if matching is based on propensity score |
est.pg |
Point estimate of ATE if matching is based on prognostic score |
est.x |
Point estimate of ATE if matching is based on covarites directly |
boot.var |
Variance of estimator estimated by bootstrap.
Meaningless if |
bootq1 |
0.025 quantile of estimator estimated by bootstrap.
Meaningless if |
bootq2 |
0.975 quantile of estimator estimated by bootstrap.
Meaningless if |
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 27 28 29 30 31 32 33 34 | # import lalonde data from package "Matching"
library(Matching)
data("lalonde")
Y = lalonde[,"re78"]
X = lalonde[,c("age","educ","black","hisp","married","nodegr","re74","re75","u74","u75")]
X = as.matrix(X)
A = lalonde[,"treat"]
# linear predictors using in the algorithm
# take logarithm for income and standardize covariates
Z = X
Z[,"re74"] = log(Z[,"re74"] + 1)
Z[,"re75"] = log(Z[,"re75"] + 1)
Z[,"age"] = (Z[,"age"] - mean(Z[,"age"])) / sd(Z[,"age"])
Z[,"educ"] = (Z[,"educ"] - mean(Z[,"educ"])) / sd(Z[,"educ"])
Z[,"re74"] = (Z[,"re74"] - mean(Z[,"re74"])) / sd(Z[,"re74"])
Z[,"re75"] = (Z[,"re75"] - mean(Z[,"re75"])) / sd(Z[,"re75"])
Z = cbind(Z, Z[,"age"]^2, Z[,"educ"]^2, Z[,"re74"]^2, Z[,"re75"]^2)
# estimate ATT using four matching methods
set.seed(1)
dsmatchATE(Y, X, A, method = "dsm", model.ps = "linpred", lp.ps = Z, model.pg = "linpred", lp.pg = Z, varest = T, cov.balance = T)
dsmatchATE(Y, X, A, method = "ps", model.ps = "linpred", lp.ps = Z, model.pg = "linpred", lp.pg = Z, varest = T, cov.balance = T)
dsmatchATE(Y, X, A, method = "pg", model.ps = "linpred", lp.ps = Z, model.pg = "linpred", lp.pg = Z, varest = T, cov.balance = T)
dsmatchATE(Y, X, A, method = "cov", model.ps = "linpred", lp.ps = Z, model.pg = "linpred", lp.pg = Z, varest = T, cov.balance = T)
# estimate QTE using double score matching
p = 0.3
set.seed(1)
res <- dsmatchQTE(Y, X, A, p, method = "dsm", model.ps = "linpred", lp.ps = Z, model.pg = "linpred", lp.pg = Z, varest = T)
res
# Wald interval for QTE
res$est.ds + qnorm(0.025) * sqrt(res$bootvar)
res$est.ds - qnorm(0.025) * sqrt(res$bootvar)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.