mlr.variance {MatchLinReg} | R Documentation |
Treatment effect variance
Description
Calculating treatment effect variance, resulting from linear regression.
Usage
mlr.variance(tr, Z.i = NULL, sigsq = 1, details = FALSE
, idx =1:length(tr))
Arguments
tr |
Binary treatment indicator vector (1=treatment, 0=control), whose coefficient in the linear regression model is TE. |
Z.i |
Matrix of adjustment covariates included in linear regression. We must have |
sigsq |
Variance of data generation noise. |
details |
Boolean flag, indicating whether intermediate objects used in generating the constrcutor vector must be returned or not (only when no repeated observations). |
idx |
Index of observations to be used, with possible duplication, e.g. as indexes of matched subset. |
Value
A scalar value is returned for TE variance. If details = TRUE
and Z.i
is not NULL
, then the following objects are attached as attributes:
u.i |
Vector of length |
A |
Weighted, within-group covariance matrix of included covariates. It is a square matrix of dimension |
iA |
Inverse of |
Author(s)
Alireza S. Mahani, Mansour T.A. Sharabiani
References
Link to a draft paper, documenting the supporting mathematical framework, will be provided in the next release.
Examples
data(lalonde)
tr <- lalonde$treat
Z.i <- as.matrix(lalonde[, c("age", "educ", "black"
, "hispan", "married", "nodegree", "re74", "re75")])
ret <- mlr.variance(tr = tr, Z.i = Z.i)
# comparing with brute-force approach
X.i <- cbind(tr, 1, Z.i)
ret2 <- (solve(t(X.i) %*% X.i))[1, 1]
cat("check 1:", all.equal(ret2, ret), "\n")
# matching with/without replacement
idx <- mlr.match(tr = tr, X = Z.i, caliper = 1.0
, replace = FALSE)
idx.wr <- mlr.match(tr = tr, X = Z.i, caliper = 1.0
, replace = TRUE)
ret3 <- mlr.variance(tr = tr, Z.i = Z.i, idx = idx)
cat("variance - matching without replacement:"
, ret3, "\n")
ret4 <- mlr.variance(tr = tr, Z.i = Z.i, idx = idx.wr)
cat("variance - matching with replacement:"
, ret4, "\n")