knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>",
  fig.path = "man/figures/README-",
  out.width = "100%"
)

didgformula

The R package didgformula implements inverse-probability weighted, iterated conditional g-computation, and doubly robust targeted maximum likelihood estimators for sustained intervention effects under parallel trends assumptions.

Installation

Only the development version is available so far. You can install it from GitHub with:

# install.packages("devtools")
devtools::install_github("audreyrenson/didgformula")

Examples

Here is a basic example using simulated data:

library(didgformula)

set.seed(10)

time_periods = 5
N_obs        = 1e4
parameters   = generate_parameters(Tt=time_periods)
df           = generate_data(N=N_obs, Tt=time_periods, Beta=parameters, ylink = 'rnorm_identity')

head(df)

We can calculate the true parameters by generating a large number of potential outcomes under the same data-generating mechanism:

df_po = generate_data(N=N_obs*10, Tt=time_periods, Beta=parameters, ylink='rnorm_identity', potential_outcomes = TRUE)

truth = colMeans(calc_ydiffs(df_po, Tt=time_periods)) #calc_ydiffs simply takes Y_t-Y_{t-1} for t=1,...,T
truth

We can estimate this using IPTW:

estimates_iptw = iptw_pipeline(data = df, den_formula = '~W{t}', Tt=time_periods)
estimates_iptw

ICE:

estimates_ice = ice_pipeline(data = df, inside_formula_t = '~W{t}', inside_formula_tmin1='~W{t-1}', outside_formula = '~W{k}', Tt=time_periods)
estimates_ice


audreyrenson/didgformula documentation built on Oct. 9, 2022, 11:45 a.m.