linpeer.sim {QuantilePeer}R Documentation

Simulating Linear Peer Effect Models

Description

linpeer.sim simulates linear peer effect models.

Usage

linpeer.sim(
  formula,
  Glist,
  parms,
  lambda,
  beta,
  epsilon,
  structural = FALSE,
  data
)

Arguments

formula

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

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.

parms

A vector defining the true values of (\lambda', \beta')', where \lambda is either the peer effect parameter for the reduced-form specification or a 2-vector with the first component being conformity peer effects and the second component representing total peer effects. The parameters \lambda and \beta can also be specified separately using the arguments lambda, and beta.

lambda

The true value of the vector \lambda.

beta

The true value of the vector \beta.

epsilon

A vector of idiosyncratic error terms. If not specified, it will be simulated from a standard normal distribution.

structural

A logical value indicating whether simulations should be performed using the structural model. The default is the reduced-form model (see the Details section of qpeer).

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 linpeer.sim is called.

Value

A list containing:

y

The simulated variable.

Gy

the average of y among friends.

See Also

qpeer, linpeer

Examples

set.seed(123)
ngr  <- 50
nvec <- rep(30, ngr)
n    <- sum(nvec)
G    <- lapply(1:ngr, function(z){
  Gz <- matrix(rbinom(nvec[z]^2, 1, 0.3), nvec[z])
  diag(Gz) <- 0
  Gz/rowSums(Gz) # Row-normalized network
})
X    <- cbind(rnorm(n), rpois(n, 2))
l    <- 0.5
b    <- c(2, -0.5, 1)

out  <- linpeer.sim(formula = ~ X, Glist = G, lambda = l, beta = b)
summary(out$y)

[Package QuantilePeer version 0.0.1 Index]