covariate_balance_test: Covariate Balance Test

Description Usage Arguments Details Value Examples

View source: R/diagnostic.R

Description

Covariate Balance Test

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
covariate_balance_test(
  data = NULL,
  aps = NULL,
  X = NULL,
  Z = NULL,
  degen = c(0, 1),
  apslab = "APS",
  xlab = c("X1"),
  zlab = "Z",
  verbose = T
)

Arguments

data

Dataset containing ML input variables X, treatment assignment Z, and aps.

aps

Vector of APS values.

X

Object containing ML inputs X.

Z

Vector of ML recommendation values Z.

degen

Vector of values for which APS is degenerate. Defaults to c(0,1).

apslab

Column name of APS variable. Defaults to "APS".

xlab

Character vector of column names of ML inputs X. Defaults to c("X1").

zlab

Column name of Z variable. Defaults to "Z".

verbose

Boolean indicator for whether to print summary output of estimation. Defaults to True.

Details

If the primary data vectors (aps, X, Z) are not passed, then the fallback is to search for the _lab variables in the data object.

This function estimates a multivariate multiple regression system, varying each of the ML input variables in X against the common covariates APS and Z, where APS is non-degenerate. The covariate balance test reports the results of each individual regression, as well as the joint hypothesis result for the coefficient on Z. This helps to establish whether APS performs adequately as a control for differences created through treatment selection. The regression system is estimated on the sample for which APS is non-degenerate.

Value

List containing fitted multivariate multiple linear model and the results of the joint hypothesis test, including the F statistic and p-value of the Pillai's trace statistic.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
# Iris data
data("iris")
assign_cutoff <- function(X, cutoff){
  ret <- as.integer(X > cutoff)
  return(ret)
}
model <- lm(Sepal.Length ~ Sepal.Width + Petal.Length + Petal.Width, data=iris)
aps <- estimate_aps(iris, model, xc = names(iris)[2:4], infer=FALSE, s=400,
        delta=0.8, fcn=assign_cutoff, cutoff = 6)
Z <- assign_cutoff(iris$Sepal.Length, 6)
X <- iris[,2:4]
iris[, APS := aps]
iris[, Z := Z]
# Two ways of sending inputs
out_direct <- covariate_balance_test(aps = aps, X = iris[, 2:4], Z = Z)
out_indirect <- covariate_balance_test(data = iris, apslab = "APS",
           xlab = names(iris)[2:4])

factoryofthesun/r-IVaps documentation built on Dec. 20, 2021, 7:41 a.m.