Description Usage Arguments Details Value Examples
dsmatchATT
applys matching algorithm to estimate average
treatment effect for the treated 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 19 20 |
Y |
Outcome as numeric vector. |
X |
Covarites as numeric vector or matrix. |
A |
Treatment assignment as numeric vector with |
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 |
caliper |
A scalar or vector denoting the caliper(s) which should
be used when matching. A caliper is the distance which is acceptable
for any match. Observations which are outside of the caliper are dropped.
If a scalar caliper is provided, this caliper is used for all covariates
in X. If a vector of calipers is provided, a caliper value should be
provided for each covariate in X. See function |
replace |
A logical flag for whether matching should be done with
replacement. Note that if FALSE, the order of matches generally matters.
See function |
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 |
... |
Additional parameters for |
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.
Some parameters in Match
in Matching
has already been
set as parameters in the function, such as caliper
and
replace
. Addtional parameters for Match
function can
also be assigned by ...
except that tie
and
Weight
has already been specified in the function.
Results are put in a list:
est.ds |
Point estimate of ATT if matching is based on double score. |
est.ps |
Point estimate of ATT if matching is based on propensity score. |
est.pg |
Point estimate of ATT if matching is based on prognostic score. |
est.x |
Point estimate of ATT 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 |
cov.bal |
standard difference in mean for all covariates. |
matching.detail |
returned object from function |
matching.rate |
matching rate due to caliper or replacement. |
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 35 36 37 38 39 40 41 42 43 44 | # import lalonde data from package "lalonde"
library(lalonde)
nsw <- lalonde::nsw
cps3 <- lalonde::cps_controls3
# combine datasets
nsw <- nsw[,-1]
cps3 <- cps3[,c(2,3,4,5,6,7,8,10,11)]
lalonde <- rbind(nsw, cps3)
# preprocessing of data
Y = lalonde[,"re78"]
Y = as.matrix(Y)
Y = as.vector(Y)
X = lalonde[,c("age","education","black","hispanic","married","nodegree","re75")]
X = as.matrix(X)
A = lalonde[,"treat"]
A = as.matrix(A)
A = as.vector(A)
# linear predictors using in the algorithm
# take logarithm for income and standardize covariates
Z = X
Z[,"re75"] = log(Z[,"re75"] + 1)
Z[,"age"] = (Z[,"age"] - mean(Z[,"age"])) / sd(Z[,"age"])
Z[,"education"] = (Z[,"education"] - mean(Z[,"education"])) / sd(Z[,"education"])
Z[,"re75"] = (Z[,"re75"] - mean(Z[,"re75"])) / sd(Z[,"re75"])
Z = cbind(X, Z[,"age"]^2, Z[,"education"]^2, Z[,"re75"]^2)
# estimate ATT using four matching methods
set.seed(1)
dsmatchATT(Y, X, A, method = "dsm", model.ps = "linpred", lp.ps = Z, model.pg = "linpred", lp.pg = Z, varest = T, cov.balance = T)
dsmatchATT(Y, X, A, method = "ps", model.ps = "linpred", lp.ps = Z, model.pg = "linpred", lp.pg = Z, varest = T, cov.balance = T)
dsmatchATT(Y, X, A, method = "pg", model.ps = "linpred", lp.ps = Z, model.pg = "linpred", lp.pg = Z, varest = T, cov.balance = T)
dsmatchATT(Y, X, A, method = "cov", model.ps = "linpred", lp.ps = Z, model.pg = "linpred", lp.pg = Z, varest = T, cov.balance = T)
# estimate QTT using double score matching
p = 0.3
set.seed(1)
res <- dsmatchQTT(Y, X, A, p, method = "dsm", model.ps = "linpred", lp.ps = Z, model.pg = "linpred", lp.pg = Z, varest = T)
res
# Wald interval for QTT
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.