spillover: Find the Optimal Targeting Order in an Intervention

View source: R/spillover.R

spilloverR Documentation

Find the Optimal Targeting Order in an Intervention

Description

spillover identifies the optimal targeting order in an intervention aimed at maximizing utilitarian welfare and computes the associated individual spillovers. The targeting order and spillovers can be generated using different targeting methods: the symmetric specification or the asymmetric specification. In the latter case, the optimal order is computed through forward or backward optimization.

Usage

spillover(
  asymodel,
  symodel,
  Glist,
  targ.net,
  data,
  treatment = 1,
  nthread = 1,
  print = TRUE,
  tol = 1e-09
)

Arguments

asymodel

An object of class asypeer.estim or summary.asypeer.estim, estimated using the asymmetric specification (asymmetry = TRUE).

symodel

An object of class asypeer.estim or summary.asypeer.estim, estimated using the symmetric specification (asymmetry = FALSE).

Glist

An adjacency matrix or a list of adjacency matrices. For networks consisting of multiple subnets (e.g., schools), Glist must be a list, where the s-th element is an n_s \times n_s adjacency matrix and n_s is the number of nodes in subnet s.

targ.net

A scalar indicating the index of the network in Glist for which the targeting order and spillovers are to be computed.

data

An optional data frame, list, environment, or any object that can be coerced to a data frame via as.data.frame, containing the variables used in the model. If a variable is not found in data, it is retrieved from the environment of asymodel.

treatment

A scalar indicating the treatment value.

nthread

The number of CPU cores (threads) used for parallel computation.

print

A logical value indicating whether a progress bar should be displayed.

tol

A numeric tolerance used to assess convergence to a post-intervention Nash equilibrium.

Value

A list containing:

targeted

A matrix or list containing the indices of the targeted individuals, ordered by their influence.

budget

A vector indicating the intervention budget (the absolute value of the total treatment) for each number of targeted individuals.

total.treat

A vector indicating the total treatment applied for each number of targeted individuals.

diff.y

A matrix containing the difference between baseline welfare and post-intervention welfare for each number of targeted individuals.

spillover

A matrix containing the spillover associated with each targeted individual.

Examples


if (requireNamespace("PartialNetwork", quietly = TRUE)) {
  library(PartialNetwork)
  ngr  <- 50  # Number of subnets
  nvec <- rep(30, ngr)  # Size of subnets
  n    <- sum(nvec)
  
  ### Simulating Data
  ## Network matrix
  G   <- lapply(1:ngr, function(z) {
    Gz <- matrix(rbinom(nvec[z]^2, 1, 0.3), nvec[z], nvec[z])
    diag(Gz) <- 0
    # Adding isolated nodes (important for the structural model)
    niso <- sample(0:nvec[z], 1, prob = ((nvec[z] + 1):1)^5 / sum(((nvec[z] + 1):1)^5))
    if (niso > 0) {
      Gz[sample(1:nvec[z], niso), ] <- 0
    }
    Gz
  })
  
  Gnorm   <- norm.network(G)
  X       <- cbind(rnorm(n, 0, 2), rpois(n, 2))
  GX      <- peer.avg(Gnorm, X)
  delta   <- 0.25
  beta    <- c(0.3, 1.6)
  gamma   <- c(4, 1, -0.7, 0, -0.5)
  eps     <- rnorm(n, 0, 0.5)
  
  ## Generating `y`
  y <- asypeer.sim(formula = ~ X + GX, Glist = Gnorm, delta = delta, beta = beta,
                   gamma = gamma, epsilon = eps)
  y <- y$y
  
  ### Estimating a symmetric peer effects model
  mod1 <- asypeer.estim(formula = y ~ X + GX, Glist = Gnorm, spillover = TRUE,
                        asymmetry = FALSE)
  summary(mod1)
  
  ### Estimating an asymmetric peer effects model
  mod2 <- asypeer.estim(formula = y ~ X + GX, Glist = Gnorm, spillover = TRUE)
  summary(mod2)
  
  ## treatment
  treat <- spillover(asymodel = mod2, symodel = mod1, Glist = Gnorm, targ.net = 1,
                     treatment = 1)
  
  ## Plot
  plot(treat)
}

AsyPeer documentation built on Nov. 2, 2026, 9:06 a.m.