Getting Started with the latenetwork Package"

knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>"
)
options(rmarkdown.html_vignette.check_title = FALSE)
library(latenetwork)

Introduction

The latenetwork package provides tools for causal inference under noncompliance with treatment assignment and network interference of unknown form. The package enables to implement the instrumental variables (IV) estimation for the local average treatment effect (LATE) type parameters via inverse probability weighting (IPW) using the concept of instrumental exposure mapping (IEM) and the framework of approximate neighborhood interference (ANI).

The parameters of interest are as follows.

For more details on the identification and estimation methods, see the "Review of Causal Inference with Noncompliance and Unknown Interference" vignette with: vignette("review", package = "latenetwork").

Installation

Get the package from CRAN:

install.packages("latenetwork")

or from GitHub:

# install.packages("devtools") # if needed
devtools::install_github("tkhdyanagi/latenetwork", build_vignettes = TRUE)

Functions

The latenetwork package provides the following functions:

Arguments

All package functions have the following arguments:

The direct() function has the following additional arguments:

The spillover() function has the following additional arguments:

Returns

Each function returns a data.frame with the following elements:

Example

To run the following example, install the igraph package if needed.

# if needed --------------------------------------------------------------------
install.packages("igraph")

Generate artificial data from the datageneration() function.

# Generate artificial data from a ring network----------------------------------
set.seed(1)
n <- 2000
data <- latenetwork::datageneration(n = n)

Perform the causal inference with:

# Arguments --------------------------------------------------------------------
Y   <- data$Y
D   <- data$D
Z   <- data$Z
A   <- data$A
IEM <- ifelse(A %*% Z > 0, 1, 0)
S   <- rep(TRUE, n)
K   <- 1
z   <- 1
t   <- 0
t0  <- 0
t1  <- 1
bw  <- NULL
B   <- NULL
alp <- 0.05

# Causal inference -------------------------------------------------------------

# The ADE parameters defined by IEM = (A %*% Z > 0)
result_direct1 <- latenetwork::direct(Y = Y,
                                      D = D,
                                      Z = Z,
                                      IEM = IEM,
                                      S = S,
                                      A = A,
                                      K = K,
                                      t = t,
                                      bw = bw,
                                      B = B,
                                      alp = alp)

# The ADE parameters defined by the constant IEM
result_direct2 <- latenetwork::direct(Y = Y,
                                      D = D,
                                      Z = Z,
                                      IEM = NULL,
                                      S = S,
                                      A = A,
                                      K = K,
                                      t = NULL,
                                      bw = bw,
                                      B = B,
                                      alp = alp)

# The AIE parameters defined by K = 1
result_indirect <- latenetwork::indirect(Y = Y,
                                         D = D,
                                         Z = Z,
                                         S = S,
                                         A = A,
                                         K = K,
                                         bw = bw,
                                         B = B,
                                         alp = alp)

# The AOE parameters defined by K = 1
result_overall <- latenetwork::overall(Y = Y,
                                       D = D,
                                       Z = Z,
                                       S = S,
                                       A = A,
                                       K = K,
                                       bw = bw,
                                       B = B,
                                       alp = alp)

# The ASE parameters defined by IEM = (A %*% Z > 0)
result_spillover <- latenetwork::spillover(Y = Y,
                                           D = D,
                                           Z = Z,
                                           IEM = IEM,
                                           S = S,
                                           A = A,
                                           K = K,
                                           z = z,
                                           t0 = t0,
                                           t1 = t1,
                                           bw = bw,
                                           B = B,
                                           alp = alp)

You can see the estimation results with:

result_direct1

result_direct2

result_indirect

result_overall

result_spillover

References

Hoshino, T. and Yanagi, T., 2023. Causal inference with noncompliance and unknown interference. arXiv preprint arXiv:2108.07455. Link

Leung, M.P. (2022). Causal inference under approximate neighborhood interference. Econometrica, 90(1), pp.267-293. Link



Try the latenetwork package in your browser

Any scripts or data that you put into this service are public.

latenetwork documentation built on Aug. 8, 2023, 5:09 p.m.