| Title: | Inference on Average Treatment Effects for Continuous Treatments |
|---|---|
| Description: | Conduct inference on the sample average treatment effect for a matched (observational) dataset with a continuous treatment. Equipped with calipered non-bipartite matching, bias-corrected sample average treatment effect estimation, and covariate-adjusted variance estimation. Matching, estimation, and inference methods are described in Frazier, Heng and Zhou (2024) <doi:10.48550/arXiv.2409.11701>. |
| Authors: | Anthony Frazier [aut, cre, cph], Siyu Heng [aut], Wen Zhou [aut] |
| Maintainer: | Anthony Frazier <[email protected]> |
| License: | GPL (>= 3) |
| Version: | 1.0.2 |
| Built: | 2026-05-16 07:25:35 UTC |
| Source: | https://github.com/anthonyfraziercsu/nbpinference |
This function estimates the sample average treatment effect for a set of matched pairs using the bias-corrected Neyman estimator, defined in Frazier et al. (2024).
bias.corrected.neyman(Y, Z, pairs, pmat, xi)bias.corrected.neyman(Y, Z, pairs, pmat, xi)
Y |
a 2I-length vector of outcome values |
Z |
a 2I-length vector of treatment values |
pairs |
an I x 2 dataframe containing the indices of observations that form our set of matched pairs. An appropriate pairs dataframe can be formed using the nbp.caliper function. |
pmat |
a 2I x 2I matrix where the diagonals equal zero, and the off-diagonal elements (i, j) contain the probability the ith observation has Z = max(Z_i, Z_j) and the jth observation has Z = min(Z_i, Z_j). We can create a p-matrix using the make.pmatrix function.A p-matrix can be created using the make.pmatrix function. |
xi |
a number in the range 0 to 0.5, the cutoff related to the treatment assignment probability caliper. |
I x 2 dataframe
Other inference:
classic.neyman(),
covAdj.variance(),
make.pmatrix(),
nbp.caliper()
set.seed(12345) X <- rnorm(100, 0, 5) Z <- X + rnorm(100, 0, (1+sqrt(abs(X)))) Y <- X + Z + rnorm(100, 0, 0.5) pmat <- make.pmatrix(Z, X) pairs <- nbp.caliper(Z, X, pmat, xi = 0.1, M = 10000) bias.corrected.neyman(Y, Z, pairs, pmat, xi = 0.1)set.seed(12345) X <- rnorm(100, 0, 5) Z <- X + rnorm(100, 0, (1+sqrt(abs(X)))) Y <- X + Z + rnorm(100, 0, 0.5) pmat <- make.pmatrix(Z, X) pairs <- nbp.caliper(Z, X, pmat, xi = 0.1, M = 10000) bias.corrected.neyman(Y, Z, pairs, pmat, xi = 0.1)
This function estimates the sample average treatment effect for a set of matched pairs using the classic Neyman estimator. For references on the classic Neyman estimator, see Baiocchi et al. (2010); Zhang et al. (2022); Heng et al. (2023)
classic.neyman(Y, Z, pairs)classic.neyman(Y, Z, pairs)
Y |
a 2I-length vector of outcome values, which must be numeric. |
Z |
a 2I-length vector of treatment values, which must be numeric. |
pairs |
an I x 2 dataframe containing the indices of observations that form our set of matched pairs. An appropriate pairs dataframe can be formed using the nbp.caliper function. |
the sample average treatment effect (numeric)
Other inference:
bias.corrected.neyman(),
covAdj.variance(),
make.pmatrix(),
nbp.caliper()
set.seed(12345) X <- rnorm(100, 0, 5) Z <- X + rnorm(100, 0, (1+sqrt(abs(X)))) Y <- X + Z + rnorm(100, 0, 0.5) pmat <- make.pmatrix(Z, X) pairs <- nbp.caliper(Z, X, pmat, xi = 0.1, M = 10000) classic.neyman(Y, Z, pairs)set.seed(12345) X <- rnorm(100, 0, 5) Z <- X + rnorm(100, 0, (1+sqrt(abs(X)))) Y <- X + Z + rnorm(100, 0, 0.5) pmat <- make.pmatrix(Z, X) pairs <- nbp.caliper(Z, X, pmat, xi = 0.1, M = 10000) classic.neyman(Y, Z, pairs)
This function calculates the covariate-adjusted conservative variance estimator For the (classic or bias-corrected) Neyman estimator. For details on the definition of the covariate-adjusted Neyman estimator, see Fogarty (2018) and Frazier et al. (2024).
covAdj.variance(Y, Z, X, pairs, pmat, xi, Q)covAdj.variance(Y, Z, X, pairs, pmat, xi, Q)
Y |
a 2I-length vector of outcome values |
Z |
a 2I-length vector of treatment values |
X |
a 2I x k matrix of covariate values |
pairs |
an I x 2 dataframe containing the indices of observations that form our set of matched pairs. An appropriate pairs dataframe can be formed using the nbp.caliper function. |
pmat |
a 2I x 2I matrix where the diagonals equal zero, and the off-diagonal elements (i, j) contain the probability the ith observation has Z = max(Z_i, Z_j) and the jth observation has Z = min(Z_i, Z_j). We can create a p-matrix using the make.pmatrix function. A p-matrix can be created using the make.pmatrix function. |
xi |
a number in the range 0 to 0.5, the cutoff related to the treatment assignment probability caliper. |
Q |
an arbitrary I x L numeric (real-valued) matrix, where L < I |
a 2I x 2I numeric matrix
Other inference:
bias.corrected.neyman(),
classic.neyman(),
make.pmatrix(),
nbp.caliper()
set.seed(12345) X <- rnorm(100, 0, 5) Z <- X + rnorm(100, 0, (1+sqrt(abs(X)))) Y <- X + Z + rnorm(100, 0, 0.5) pmat <- make.pmatrix(Z, X) pairs <- nbp.caliper(Z, X, pmat, xi = 0.1, M = 10000) covAdj.variance(Y, Z, X, pairs, pmat, xi = 0.1)set.seed(12345) X <- rnorm(100, 0, 5) Z <- X + rnorm(100, 0, (1+sqrt(abs(X)))) Y <- X + Z + rnorm(100, 0, 0.5) pmat <- make.pmatrix(Z, X) pairs <- nbp.caliper(Z, X, pmat, xi = 0.1, M = 10000) covAdj.variance(Y, Z, X, pairs, pmat, xi = 0.1)
This function creates some example data using the data generation process described in simulation 1 of (Frazier et al. 2024). The dataframe contains a treatment variable Z, outcome variable Y, and five covariates X1,...,X5.
generate.data.dose(N)generate.data.dose(N)
N |
Number of observations to simulate, which should be a positive whole number. |
an N x 7 matrix containing treatment, outcome, and covariates.
Other data generation:
generate.data.dose2()
generate.data.dose(N = 100)generate.data.dose(N = 100)
This function creates some example data using the data generation process for the secondary set of simulations described in the supplementary materials of Frazier A, Heng S, Zhou W (2024). “Bias Reduction in Matched Observational Studies with Continuous Treatments: Calipered Non-Bipartite Matching and Bias-Corrected Estimation and Inference.” arXiv e-prints, arXiv–2409.. The dataframe contains a treatment variable Z, outcome variable Y, and five covariate X1,...,X6
generate.data.dose2(N)generate.data.dose2(N)
N |
Number of observations to simulate, which should be a positive whole number. |
an N x 8 matrix containing treatment, outcome, and covariates.
Other data generation:
generate.data.dose()
generate.data.dose2(N = 100)generate.data.dose2(N = 100)
This function creates a N x N matrix where the diagonals equal zero, and the off-diagonal elements (i, j) contain the probability the ith observation has Z = max(Z_i, Z_j) and the jth observation has Z = min(Z_i, Z_j), conditioned on covariates. Uses the "model-based" conditional density estimation method described in (Frazier et al. 2024).
make.pmatrix(Z, X)make.pmatrix(Z, X)
Z |
an N-length vector of treatment values, which must be numeric. |
X |
an N x k matrix of covariate values, which must be numeric. |
an N x N numeric matrix. Each entry represents the probability the ith observation has Z = max(Z_i, Z_j) and the jth observation has Z = min(Z_i, Z_j), conditioned on covariates.
Other inference:
bias.corrected.neyman(),
classic.neyman(),
covAdj.variance(),
nbp.caliper()
set.seed(12345) X <- rnorm(100, 0, 5) Z <- X + rnorm(100, 0, (1+sqrt(abs(X)))) make.pmatrix(Z, X)set.seed(12345) X <- rnorm(100, 0, 5) Z <- X + rnorm(100, 0, (1+sqrt(abs(X)))) make.pmatrix(Z, X)
This function creates a I x 2 dataframe containing the indices of observations that form our set of matched pairs. It uses the nbpMatch package (Lu et al. 2011) along with a p-matrix in order to create I matched pairs using a treatment assignment caliper. A p-matrix can be created using the make.pmatrix function.
nbp.caliper(Z, X, pmat, xi = 0, M = 0)nbp.caliper(Z, X, pmat, xi = 0, M = 0)
Z |
a 2I-length vector of treatment values, which must be numeric. |
X |
a 2I x k matrix of covariate values, which must be numeric. |
pmat |
a 2I x 2I symmetric matrix where the diagonals equal zero, and the off-diagonal elements (i, j) contain the probability the ith observation has Z = max(Z_i, Z_j) and the jth observation has Z = min(Z_i, Z_j). A p-matrix can be made using the make.pmatrix function. |
xi |
a number in the range 0 to 0.5, the cutoff related to the treatment assignment probability caliper. |
M |
an integer determining the penalty of the treatment assignment probability caliper. If a potential matched pair between observations i and j has treatment assignment probability less than xi or greater than 1-xi, add M to the distance matrix in the (i, j) and (j, i) entry. |
I x 2 dataframe
Other inference:
bias.corrected.neyman(),
classic.neyman(),
covAdj.variance(),
make.pmatrix()
set.seed(12345) X <- rnorm(100, 0, 5) Z <- X + rnorm(100, 0, (1+sqrt(abs(X)))) pmat <- make.pmatrix(Z, X) nbp.caliper(Z, X, pmat, xi = 0.1, M = 10000)set.seed(12345) X <- rnorm(100, 0, 5) Z <- X + rnorm(100, 0, (1+sqrt(abs(X)))) pmat <- make.pmatrix(Z, X) nbp.caliper(Z, X, pmat, xi = 0.1, M = 10000)