Title: | Inference on Average Treatment Effects for Continuous Treatments |
Version: | 1.0.3 |
Maintainer: | Anthony Frazier <anthony.frazier@colostate.edu> |
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>. |
Imports: | nbpMatching, stats, Rdpack |
RdMacros: | Rdpack |
URL: | https://github.com/AnthonyFrazierCSU/nbpInference |
License: | GPL (≥ 3) |
Encoding: | UTF-8 |
RoxygenNote: | 7.3.1 |
Suggests: | testthat (≥ 3.0.0) |
Config/testthat/edition: | 3 |
BugReports: | https://github.com/AnthonyFrazierCSU/nbpInference/issues |
NeedsCompilation: | no |
Packaged: | 2025-10-12 21:17:37 UTC; iaman |
Author: | Anthony Frazier [aut, cre, cph], Siyu Heng [aut], Wen Zhou [aut] |
Repository: | CRAN |
Date/Publication: | 2025-10-17 20:10:07 UTC |
Bias-corrected Neyman Sample Average Treatment Effect Estimator
Description
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).
Usage
bias.corrected.neyman(Y, Z, pairs, pmat, xi)
Arguments
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. |
Value
I x 2 dataframe
See Also
Other inference:
classic.neyman()
,
covAdj.variance()
,
make.pmatrix()
,
nbp.caliper()
Examples
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)
Classic Neyman Sample Average Treatment Effect Estimator
Description
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)
Usage
classic.neyman(Y, Z, pairs)
Arguments
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. |
Value
the sample average treatment effect (numeric)
See Also
Other inference:
bias.corrected.neyman()
,
covAdj.variance()
,
make.pmatrix()
,
nbp.caliper()
Examples
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)
Covariate-Adjusted Variance Estimation
Description
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).
Usage
covAdj.variance(Y, Z, X, pairs, pmat, xi, Q)
Arguments
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 |
Value
a 2I x 2I numeric matrix
See Also
Other inference:
bias.corrected.neyman()
,
classic.neyman()
,
make.pmatrix()
,
nbp.caliper()
Examples
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)
Generate example data with five covariates
Description
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.
Usage
generate.data.dose(N)
Arguments
N |
Number of observations to simulate, which should be a positive whole number. |
Value
an N x 7 matrix containing treatment, outcome, and covariates.
See Also
Other data generation:
generate.data.dose2()
Examples
generate.data.dose(N = 100)
Generate sample data with six covariates
Description
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
Usage
generate.data.dose2(N)
Arguments
N |
Number of observations to simulate, which should be a positive whole number. |
Value
an N x 8 matrix containing treatment, outcome, and covariates.
See Also
Other data generation:
generate.data.dose()
Examples
generate.data.dose2(N = 100)
Make matrix of treatment assignment probabilities
Description
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).
Usage
make.pmatrix(Z, X)
Arguments
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. |
Value
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.
See Also
Other inference:
bias.corrected.neyman()
,
classic.neyman()
,
covAdj.variance()
,
nbp.caliper()
Examples
set.seed(12345)
X <- rnorm(100, 0, 5)
Z <- X + rnorm(100, 0, (1+sqrt(abs(X))))
make.pmatrix(Z, X)
non-bipartite matching with treatment assignment caliper
Description
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.
Usage
nbp.caliper(Z, X, pmat, xi = 0, M = 0)
Arguments
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. |
Value
I x 2 dataframe
See Also
Other inference:
bias.corrected.neyman()
,
classic.neyman()
,
covAdj.variance()
,
make.pmatrix()
Examples
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)