mlr.bias | R Documentation |
Calculating treatment effect bias due to misspecified regression, using coefficients of omitted covariates (if supplied) or a constrained bias estimation approach.
mlr.bias(tr, Z.i = NULL, Z.o, gamma.o = NULL , idx = 1:length(tr))
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 |
Z.o |
Matrix of adjustment covariates (present in generative model but) omitted from regression estimation. We must have |
gamma.o |
Vector of coefficients for omitted adjustment covariates. |
idx |
Index of observations to be used, with possible duplication, e.g. as indexes of matched subset. |
For single
, subspace
and absolute
, biases are calculated using the constrained bias estimation framework, i.e. L2 norm of Z.o%*%gamma.o
is taken to be length(tr)
(mean squared of 1).
A list with the following elements is returned:
gamma.o |
If function argument |
single |
A list with elements: 1) |
subspace |
A list with elements: 1) |
absolute |
A list with elements: 1) |
Alireza S. Mahani, Mansour T.A. Sharabiani
Link to a draft paper, documenting the supporting mathematical framework, will be provided in the next release.
# number of included adjustment covariates K <- 10 # number of observations in treatment group Nt <- 100 # number of observations in control group Nc <- 100 N <- Nt + Nc # number of omitted covariates Ko <- 3 # treatment indicator variable tr <- c(rep(1, Nt), rep(0, Nc)) # matrix of included (adjustment) covariates Z.i <- matrix(runif(K*N), ncol = K) # matrix of omitted covariates Z.o <- matrix(runif(Ko*N), ncol = Ko) # coefficients of omitted covariates gamma.o <- runif(Ko) retobj <- mlr.bias(tr = tr, Z.i = Z.i, Z.o = Z.o, gamma.o = gamma.o) # 1) using actual coefficients for computing bias ret <- retobj$gamma.o # comparing with brute-force approach X.i <- cbind(tr, 1, Z.i) ret2 <- (solve(t(X.i) %*% X.i, t(X.i) %*% Z.o %*% gamma.o))[1] cat("check 1:", all.equal(ret2, ret), "\n") # comparing with single method Z.o.proj <- mlr.orthogonalize(X = cbind(1, Z.i), Z = Z.o, normalize = TRUE) ret3 <- (solve(t(X.i) %*% X.i, t(X.i) %*% Z.o.proj))[1, ] cat("check 2:", all.equal(ret3, retobj$single$bias.vec), "\n") ret4 <- (solve(t(X.i) %*% X.i, t(X.i) %*% retobj$subspace$dir))[1, ] cat("check 3:", all.equal(as.numeric(ret4), as.numeric(retobj$subspace$bias)), "\n") ret4 <- (solve(t(X.i) %*% X.i, t(X.i) %*% retobj$absolute$dir))[1, ] cat("check 4:", all.equal(as.numeric(ret4), as.numeric(retobj$absolute$bias)), "\n")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.