hackint_lm: Hacking intervals for linear models

Description Usage Arguments Value Examples

View source: R/hackint.R

Description

Computes tethered and constraint-based hacking intervals of the coefficient of a binary treatment variable in a linear model. See https://github.com/beauCoker/hacking for examples.

Usage

1
2
hackint_lm(mdl, data, treatment, theta = 0.1, frac_remove_obs = 1,
  verbose = TRUE)

Arguments

mdl

lm object representing the "base" model

data

data.frame used to fit mdl

treatment

name of binary treatment variable (inputted as character)

theta

loss tolerance for tethered hacking (default = 0.1)

frac_remove_obs

fraction of observations to consider for removal (default = 1, meaning all observations considered)

verbose

whether or not to print summary

Value

list containing all hacking intervals (tethered, constrained, tethered_and_constrained) as well as complete list of all manipulations applied to the base model (hacks_all)

Examples

1
2
3
4
5
6
7
8
9
N = 50 # Number of observations
data <- data.frame(
  y = rnorm(N), # Response variable (continuous)
  w = rbinom(N, 1, .5), # Treatment variable (binary)
  X = matrix(rnorm(N*3), nrow=N), # Covariates included in base model
  Z = matrix(rnorm(N*3), nrow=N) # Covariates excluded from base model
)
mdl <- lm(y ~ w + X.1*X.2, data=data) # fit linear "base" model
output <- hackint_lm(mdl, data, theta=0.1, treatment = 'w')

beauCoker/hacking documentation built on Nov. 4, 2019, 7:08 a.m.