Title: | Selection Bias Approach to Sensitivity Analysis for Causal Effects |
---|---|
Description: | The causalsens package provides functions to perform sensitivity analyses and to study how various assumptions about selection bias affects estimates of causal effects. |
Authors: | Matthew Blackwell <[email protected]> |
Maintainer: | Matthew Blackwell <[email protected]> |
License: | GPL (>= 2) |
Version: | 0.1.3 |
Built: | 2024-11-13 03:57:44 UTC |
Source: | https://github.com/mattblackwell/causalsens |
This function performs a sensitivity analysis of causal effects different assumptions about unmeasured confounding, as described by Blackwell (2013).
causalsens( model.y, model.t, cov.form, confound = one.sided, data, alpha, level = 0.95 )
causalsens( model.y, model.t, cov.form, confound = one.sided, data, alpha, level = 0.95 )
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. |
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.
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)
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)
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.
data(lalonde.exp)
data(lalonde.exp)
A data frame with 445 rows and 12 variables
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.
LaLonde, Robert J. (1986). Evaluating the Econometric Evaluations of Training Programs with Experimental Data. The American Economic Review, 76(4), 604–620.
A dataset of experimental treated units and non-experimental control units from the Panel Study of Income Dynamics (PSID).
data(lalonde.psid)
data(lalonde.psid)
A data frame with 2675 rows and 12 variables
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.
LaLonde, Robert J. (1986). Evaluating the Econometric Evaluations of Training Programs with Experimental Data. The American Economic Review, 76(4), 604–620.
Various confounding functions for use with
causalsens
.
one.sided(alpha, pscores, treat) alignment(alpha, pscores, treat) one.sided.att(alpha, pscores, treat) alignment.att(alpha, pscores, treat)
one.sided(alpha, pscores, treat) alignment(alpha, pscores, treat) one.sided.att(alpha, pscores, treat) alignment.att(alpha, pscores, treat)
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 the results of a sensitivity analysis against unmeasured
confounding as perfomed by causalsens
## S3 method for class 'causalsens' plot(x, type = "r.squared", ...)
## S3 method for class 'causalsens' plot(x, type = "r.squared", ...)
x |
|
type |
a string taking either the value |
... |
other parameters to pass to the plot. |