Version: | 0.1.3 |
Date: | 2024-03-18 |
Title: | Selection Bias Approach to Sensitivity Analysis for Causal Effects |
Author: | Matthew Blackwell <mblackwell@gov.harvard.edu.edu> |
Maintainer: | Matthew Blackwell <mblackwell@gov.harvard.edu> |
Imports: | stats, graphics, grDevices |
Depends: | R (≥ 3.0.0) |
Description: | The causalsens package provides functions to perform sensitivity analyses and to study how various assumptions about selection bias affects estimates of causal effects. |
License: | GPL-2 | GPL-3 [expanded from: GPL (≥ 2)] |
URL: | https://www.mattblackwell.org/software/causalsens/ |
VignetteBuilder: | knitr |
Suggests: | rmarkdown, knitr |
Encoding: | UTF-8 |
Collate: | 'causalsens.R' |
RoxygenNote: | 7.0.2 |
NeedsCompilation: | no |
Packaged: | 2024-03-18 16:27:21 UTC; mblackwell |
Repository: | CRAN |
Date/Publication: | 2024-03-18 20:40:02 UTC |
Calculate sensitivity of causal estimates to unmeasured confounding.
Description
This function performs a sensitivity analysis of causal effects different assumptions about unmeasured confounding, as described by Blackwell (2013).
Usage
causalsens(
model.y,
model.t,
cov.form,
confound = one.sided,
data,
alpha,
level = 0.95
)
Arguments
model.y |
outcome model object. Currently only handles
|
model.t |
propensity score model. Currently assumes a
|
cov.form |
one-sided formula to describe any covariates to be included in the parital R^2 calculations. |
confound |
function that calculates the confounding
function. This function must take arguments |
data |
data frame to find the covariates from |
alpha |
vector of confounding values to pass the confounding function. Defaults to 11 points from -0.5 to 0.5 for binary outcome variable, and 11 points covering the a interval with width equal to the inter-quartile range and centered at 0 for non-binary outcome variables. |
level |
level of the confidence interval returned. |
Value
Returns an object of class causalsens
.
-
sens
data frame containing alpha values, partial R^2s, estimates, and 95 -
partial.r2
vector of partial R^2 values for the covariates to compare to sensitivity analysis results.
Examples
data(lalonde.exp)
ymodel <- lm(re78 ~ treat+age + education + black + hispanic +
married + nodegree + re74 + re75 + u74 + u75, data = lalonde.exp)
pmodel <- glm(treat ~ age + education + black + hispanic + married
+ nodegree + re74 + re75 + u74 + u75, data = lalonde.exp,
family = binomial())
alpha <- seq(-4500, 4500, by = 250)
ll.sens <- causalsens(ymodel, pmodel, ~ age + education, data =
lalonde.exp, alpha = alpha, confound = one.sided.att)
Experimental data from the job training program first studied by LaLonde (1986)
Description
A dataset of units in an experimental evaluation of a job training program. Subset to those units with two years of pre-treatment income data.
Usage
data(lalonde.exp)
Format
A data frame with 445 rows and 12 variables
Details
-
age
- age in years. -
education
- number of years of schooling. -
black
- 1 if black, 0 otherwise. -
hispanic
- 1 if Hispanic, 0 otherwise. -
married
- 1 if married, 0 otherwise. -
nodegree
- 1 if no high school degree, 0 otherwise. -
re74
- earnings ($) in 1974. -
re75
- earnings ($) in 1975. -
re78
- earnings ($) in 1978. -
u74
- 1 if unemployed in 1974, 0 otherwise. -
u75
- 1 if unemployed in 1975, 0 otherwise. -
treat
- 1 if treated, 0 otherwise.
References
LaLonde, Robert J. (1986). Evaluating the Econometric Evaluations of Training Programs with Experimental Data. The American Economic Review, 76(4), 604–620.
Non-experimental data from Lalonde (1986)
Description
A dataset of experimental treated units and non-experimental control units from the Panel Study of Income Dynamics (PSID).
Usage
data(lalonde.psid)
Format
A data frame with 2675 rows and 12 variables
Details
-
age
- age in years. -
education
- number of years of schooling. -
black
- 1 if black, 0 otherwise. -
hispanic
- 1 if Hispanic, 0 otherwise. -
married
- 1 if married, 0 otherwise. -
nodegree
- 1 if no high school degree, 0 otherwise. -
re74
- earnings ($) in 1974. -
re75
- earnings ($) in 1975. -
re78
- earnings ($) in 1978. -
u74
- 1 if unemployed in 1974, 0 otherwise. -
u75
- 1 if unemployed in 1975, 0 otherwise. -
treat
- 1 if treated, 0 otherwise.
References
LaLonde, Robert J. (1986). Evaluating the Econometric Evaluations of Training Programs with Experimental Data. The American Economic Review, 76(4), 604–620.
Confounding functions
Description
Various confounding functions for use with
causalsens
.
Usage
one.sided(alpha, pscores, treat)
alignment(alpha, pscores, treat)
one.sided.att(alpha, pscores, treat)
alignment.att(alpha, pscores, treat)
Arguments
alpha |
vector of confounding values to use in the sensitivity analysis. |
pscores |
vector of propensity scores for each unit. |
treat |
vector of treatment values for each unit. |
Plot a causal sensitivity analysis.
Description
Plot the results of a sensitivity analysis against unmeasured
confounding as perfomed by causalsens
Usage
## S3 method for class 'causalsens'
plot(x, type = "r.squared", ...)
Arguments
x |
|
type |
a string taking either the value |
... |
other parameters to pass to the plot. |