mlr.bias.constructor {MatchLinReg}R Documentation

Generating the treatment effect bias constructor vector

Description

Generaring the vector that, multiplied by Z.o%*%gamma.o (contribution of omitted covariates to outcome), produces the treatment effect bias - due to model misspecification in the form of covariate omission - when using linear regression for causal inference.

Usage

mlr.bias.constructor(tr, Z.i = NULL, 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 nrow(Z.i) == length(tr).

details

Boolean flag, indicating whether intermediate objects used in generating the constrcutor vector must be returned or not. This only works if at least one adjustment covariate is included in the regression (Z.i is not NULL), and there are no repeated observations, i.e. max(table(idx))==1.

idx

Index of observations to be used, with possible duplication, e.g. as indexes of matched subset.

Value

A vector of same length as tr is returned. If details = TRUE and Z.i is not NULL, then the following objects are attached as attributes:

p

Vector of length ncol(Z.i), reflecting the sum of each included covariate in treatment group.

q

Vector of length ncol(Z.i), reflecting the sum of each included covariate across both treatment and control groups.

u.i

Vector of length ncol(Z.i), reflecting the mean difference between groups (control - treatment) for each included covariate.

A

Weighted, within-group covariance matrix of included covariates. It is a square matrix of dimension ncol(Z.i).

iA

Inverse of A.

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


# 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

# treatment indicator variable
tr <- c(rep(1, Nt), rep(0, Nc))
# matrix of included (adjustment) covariates
Z.i <- matrix(runif(K*N), ncol = K)

ret <- mlr.bias.constructor(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, t(X.i)))[1, ]

cat("check 1:", all.equal(ret2, ret), "\n")

# sampling with replacement
idx <- sample(1:N, size = round(0.75*N), replace = TRUE)
ret3 <- mlr.bias.constructor(tr = tr, Z.i = Z.i, idx = idx)
ret4 <- (solve(t(X.i[idx, ]) %*% X.i[idx, ], t(X.i[idx, ])))[1, ]

cat("check 2:", all.equal(ret3, ret4), "\n")


[Package MatchLinReg version 0.8.1 Index]