cesconfpeer: Estimation of CES-Based Peer Effects Models With Conformity

View source: R/peer.ces.R

cesconfpeerR Documentation

Estimation of CES-Based Peer Effects Models With Conformity

Description

cesconfpeer estimates the CES-based peer effects model introduced by Boucher et al. (2024) with conformity only. See Details.

Usage

cesconfpeer(
  formula,
  instrument,
  Glist,
  fixed.effects = FALSE,
  set.rho = NULL,
  interval = c(-100, 100),
  tol = 1e-08,
  drop = NULL,
  HAC = "group-iid",
  nthread = 1,
  data,
  n.rho0 = 10,
  n.beta0 = 5,
  weight.rho = NULL,
  weight.optim = TRUE,
  arg.optim = list(),
  ...
)

plotcespeer(
  formula,
  instrument,
  Glist,
  fixed.effects = FALSE,
  grid.rho = seq(-50, 50, 0.1),
  tol = 1e-08,
  drop = NULL,
  nthread = 1,
  data,
  weight.rho = NULL,
  arg.optim = list(),
  ...
)

Arguments

formula

An object of class formula: a symbolic description of the model. formula should be specified as y ~ x1 + x2, where y is the outcome and x1 and x2 are control variables, which can include contextual variables such as averages or quantiles among peers.

instrument

An object of class formula indicating the excluded instrument. It should be specified as ~ z, where z is the excluded instrument for the outcome. Following Boucher et al. (2024), it can be an OLS exogenous prediction of y. This prediction is used to compute instruments for the CES function of peer outcomes.

Glist

The adjacency matrix. For networks consisting of multiple subnets (e.g., schools), Glist must be a list of subnets, with the m-th element being an n_m \times n_m adjacency matrix, where n_m is the number of nodes in the m-th subnet.

fixed.effects

A logical value or string specifying whether the model includes subnet fixed effects.

set.rho

A fixed value for the CES substitution parameter to estimate a constrained model.

interval

A numerical vector of two elements indicating support for \rho.

tol

A tolerance value used in the QR factorization to identify columns of explanatory variable and instrument matrices that ensure a full-rank matrix (see the qr function). The same tolerance is also used in the to minimize the concentrated GMM objective function (see optimise).

drop

A dummy vector of the same length as the sample, indicating whether an observation should be dropped. This can be used, for example, to remove false isolates or to estimate the model only on non-isolated agents. These observations cannot be directly removed from the network by the user because they may still be friends with other agents.

HAC

A character string specifying the correlation structure of the idiosyncratic errors for covariance computation. Options are "iid" for independent errors; "group iid" for independence within the groups of isolated and non-isolated players; "hetero" for heteroskedastic but non-autocorrelated errors; and "cluster" for heteroskedastic errors with potential within-subnetwork correlation.

nthread

Number of CPU cores (threads) used to run parts of the estimation in parallel.

data

An optional data frame, list, or environment (or an object that can be coerced by as.data.frame to a data frame) containing the variables in the model. If not found in data, the variables are taken from environment(formula), typically the environment from which cesconfpeer is called.

n.rho0, n.beta0

Integer values indicating the number of starting points to test for \rho and \beta, respectively. Because the objective function may exhibit local optima, testing multiple starting values is useful, especially for \rho. On a reasonable parameter set, testing ten starting values often suffices.

weight.rho

The \rho value used to compute the weighting matrix for the first GMM estimation or to plot the objective function. The weight is computed as proportional to (Z'Z)^{-1}, where Z is the matrix of instruments. If weight.rho is omitted, the identity matrix is used.

weight.optim

A Boolean indicating whether the GMM with the optimal weighting matrix should be computed.

arg.optim

A list of additional arguments passed to optim, such as method and control, for models with a flexible \rho, or to optimize, such as tol, for models with a fixed (or grid) value of \rho. For models with a flexible \rho, the objective function is concentrated in a function of \rho and \beta, which is optimized using optim. For models with a fixed \rho, the objective function is concentrated in a function of \beta alone, which is optimized using optimize.

...

Further arguments passed to or from other methods.

grid.rho

A finite grid of values for the CES substitution parameter \rho (see Details). This grid is used to plot the objective function after maximizing over the other parameters. It is helpful for determining a reasonable interval for \rho.

Details

Let \mathcal{N} denote a set of n agents indexed by i \in [1, n]. Agents are connected through a network represented by an adjacency matrix \mathbf{G} = [g_{ij}] of dimension n \times n, where g_{ij} = 1 if agent j is a friend of agent i, and g_{ij} = 0 otherwise. In weighted networks, g_{ij} can be a nonnegative value (not necessarily binary) that measures the intensity of the outgoing link from i to j. The model accommodates such networks. Note that the network may consist of multiple independent subnets (e.g., schools). The Glist argument is the list of subnets. For a single subnet, Glist should be a list containing one matrix.

The specification of the CES-based peer effects model differs for isolated and non-isolated individuals. For an isolated agent i, the specification is similar to a standard linear-in-means model without social interactions:

y_i = \mathbf{x}_i^{\prime}\gamma + \varepsilon_i,

where \varepsilon_i is an idiosyncratic error term and \gamma captures the effect of \mathbf{x}_i on y_i.

If agent i is non-isolated, the specification is:

y_i = \dfrac{\beta}{1 + \beta}\left(\sum_{j = 1}^n g_{ij}y_j^{\rho}\right)^{1/\rho} + (1 - \lambda_2)\mathbf{x}_i^{\prime}\dfrac{\gamma}{1 + \beta} + \varepsilon_i,

where \gamma captures conformity effects—how agent i tends to conform to friends through the social norm \left(\sum_{j = 1}^n g_{ij}y_j^{\rho}\right)^{1/\rho}.

The parameter \rho determines the form of the social norm:

  • When \rho > 1, individuals are more sensitive to peers with high outcomes.

  • When \rho < 1, individuals are more sensitive to peers with low outcomes.

  • When \rho = 1, peer effects are uniform across peer outcome values.

Value

A list containing:

model.info

A list with information about the model, including the number of subnets, the number of observations, and other key details.

gmm

A list of GMM estimation results, including parameter estimates, the covariance matrix, and related statistics.

first.gmm

Initial GMM estimation results using the identity matrix as the weighting matrix.

Examples


if (requireNamespace("PartialNetwork", quietly = TRUE)) {
library(PartialNetwork)
set.seed(123)
ngr  <- 30  # 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 
  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))
delta   <- 0
beta    <- c(1, 1)
gamma   <- c(6, 1, 0.7)
eps     <- rnorm(n, 0, 0.5)

## Generating `y`
y <- asypeer.sim(formula = ~ X, Glist = Gnorm, delta = delta, beta = beta,
                 gamma = gamma, epsilon = eps)
y <- y$y

### Estimating the asymmetric peer effects model
z   <- predict(lm(y ~ X))
plotcespeer(formula = y ~ X, instrument = ~ z, Glist = Gnorm, 
            grid.rho = seq(-20, 20, 1))
est <- cesconfpeer(formula = y ~ X, instrument = ~ z, Glist = Gnorm,
                   n.rho0 = 2, n.beta0 = 1)
summary(est)
}


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