Package 'causalsens'

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

Help Index


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 lm objects.

model.t

propensity score model. Currently assumes a glm object.

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 alpha, pscores, and treat. Defaults to one.sided. Other functions included with the package are one.sided.att, alignment, and alignment.att.

data

data frame to find the covariates from cov.form.

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

causalsens object.

type

a string taking either the value "r.squared" (default), which plots the estimated effects as a function of the partial R-squared values, or "raw", which plots them as a function of the raw confounding values, alpha.

...

other parameters to pass to the plot.