| cesconfpeer | R Documentation |
cesconfpeer estimates the CES-based peer effects model introduced by Boucher et al. (2024) with conformity only. See Details.
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(),
...
)
formula |
An object of class formula: a symbolic description of the model. |
instrument |
An object of class formula indicating the excluded instrument. It should be specified as |
Glist |
The adjacency matrix. For networks consisting of multiple subnets (e.g., schools), |
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 |
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 |
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 |
n.rho0, n.beta0 |
Integer values indicating the number of starting points
to test for |
weight.rho |
The |
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 |
... |
Further arguments passed to or from other methods. |
grid.rho |
A finite grid of values for the CES substitution parameter |
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.
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. |
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)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.