gob: Computes a point estimate and confidence interval using the...

Description Usage Arguments Details Value Examples

View source: R/main.R

Description

'gob' implements the Generalized Oaxaca-Blinder covariate adjustment of Guo and Basse (2020). The function currently supports linear models and generalized linear models out of the box; it allows allows the specification of custom regression functions.

Usage

1
gob(form, Z, pred.fn.ls = NULL, data = NULL, alpha = 0.95)

Arguments

form

A formula or a call-formula (see details for 'call-formula').

Z

A vector of assignments.

pred.fn.ls

A list of learners for the treatment and control potential outcomes (see details).

data

(optional) A dataframe whose columns include all the variables referenced in 'form'.

If 'NULL', the variables in 'form' will be taken from the calling environment.

alpha

The confidence level (defaults to 0.95).

Details

Adjustment via linear and generalized linear models is as easy as:

> gob(lm(Y ~ X1 + X2), Z)

or

> gob(glm(Y ~ X1 + X2, family=gaussian), Z)

for linear adjustment. Nonlinear adjustment via the 'glm' function is also straightforward, e.g.

> gob(glm(Y ~ X1 + X2, family=Poisson), Z)

Value

A list whose first element is a point estimate, and second element is a confidence interval.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
library(RGOB)
N <- 100
X <- rnorm(N); B <- rnorm(N); C <- rnorm(N)
Z <- sample(c(0,1), N, replace=TRUE)
Y <- 1 + 0.2 * X + 0.5 * Z + rnorm(N, sd=0.1)
Yb <- ifelse(Y > 1.2, 1, 0)
dat <- data.frame(Yp=Y, D=X, E=B, F=C, Ybp=Yb)

# Using lm for covariate adjustment
gob(lm(Y ~ X + B), Z)
gob(lm(Yp~ D + E), Z, data=dat)

# Using logistic regression adjustment
gob(glm(Yb ~ X + B, family=binomial(link="logit")), Z)
gob(glm(Ybp ~ D + E, family=binomial(link="logit")), Z, data=dat)

gwb/RGOB documentation built on May 14, 2021, 7:39 a.m.