Description Usage Arguments Value Author(s) References Examples

`AsyVar`

estimates the asymptotic variance of the ATE obtained with the CBPS or oCBPS method. It also returns the finite variance estimate, the finite standard error, and a CI for the ATE.

1 2 3 4 5 6 7 8 9 10 11 12 |

`Y` |
The vector of actual outcome values (observations). |

`Y_1_hat` |
The vector of estimated outcomes according to the treatment model. (AsyVar automatically sets the treatment model as a linear regression model and it is fitted within the function.) If |

`Y_0_hat` |
The vector of estimated outcomes according to the control model. (AsyVar automatically sets the control model as a linear regression model and it is fitted within the function.) If |

`CBPS_obj` |
An object obtained with the CBPS function. If this object is not sepecified, then |

`method` |
The specific method to be considered. Either |

`X` |
The matrix of covariates with the rows corresponding to the observations and the columns corresponding to the variables. The left most column must be a column of 1's for the intercept. ( |

`TL` |
The vector of treatment labels. More specifically, the label is 1 if it is in the treatment group and 0 if it is in the control group. ( |

`pi` |
The vector of estimated propensity scores. ( |

`mu` |
The estimated average treatment effect obtained with either the CBPS or oCBPS method. ( |

`CI` |
The specified confidence level (between 0 and 1) for calculating the confidence interval for the average treatment effect. Default value is 0.95. |

`mu.hat` |
The estimated average treatment effect, |

`asy.var` |
The estimated asymptotic variance of |

`var` |
The estimated variance of |

`std.err` |
The standard error of |

`CI.mu.hat` |
The confidence interval of |

Inbeom Lee

Fan, Jianqing and Imai, Kosuke and Lee, Inbeom and Liu, Han and Ning, Yang and Yang, Xiaolin. 2021. “Optimal Covariate Balancing Conditions in Propensity Score Estimation.” Journal of Business & Economic Statistics. https://imai.fas.harvard.edu/research/CBPStheory.html

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 | ```
#GENERATING THE DATA
n=300
#Initialize the X matrix.
X_v1 <- rnorm(n,3,sqrt(2))
X_v2 <- rnorm(n,0,1)
X_v3 <- rnorm(n,0,1)
X_v4 <- rnorm(n,0,1)
X_mat <- as.matrix(cbind(rep(1,n), X_v1, X_v2, X_v3, X_v4))
#Initialize the Y_1 and Y_0 vector using the treatment model and the control model.
Y_1 <- X_mat %*% matrix(c(200, 27.4, 13.7, 13.7, 13.7), 5, 1) + rnorm(n)
Y_0 <- X_mat %*% matrix(c(200, 0 , 13.7, 13.7, 13.7), 5, 1) + rnorm(n)
#True Propensity Score calculation.
pre_prop <- X_mat[,2:5] %*% matrix(c(0, 0.5, -0.25, -0.1), 4, 1)
propensity_true <- (exp(pre_prop))/(1+(exp(pre_prop)))
#Generate T_vec, the treatment vector, with the true propensity scores.
T_vec <- rbinom(n, size=1, prob=propensity_true)
#Now generate the actual outcome Y_outcome (accounting for treatment/control groups).
Y_outcome <- Y_1*T_vec + Y_0*(1-T_vec)
#Use oCBPS.
ocbps.fit <- CBPS(T_vec ~ X_mat, ATT=0, baseline.formula = ~X_mat[,c(1,3:5)],
diff.formula = ~X_mat[,2])
#Use the AsyVar function to get the asymptotic variance of the
#estimated average treatment effect and its confidence interval when using oCBPS.
AsyVar(Y=Y_outcome, CBPS_obj=ocbps.fit, method="oCBPS", CI=0.95)
#Use CBPS.
cbps.fit <- CBPS(T_vec ~ X_mat, ATT=0)
#Use the AsyVar function to get the asymptotic variance of the
#estimated average treatment effect and its confidence interval when using CBPS.
AsyVar(Y=Y_outcome, CBPS_obj=cbps.fit, method="CBPS", CI=0.95)
``` |

Embedding an R snippet on your website

Add the following code to your website.

For more information on customizing the embed code, read Embedding Snippets.