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. |
Glist |
The adjacency matrix. For networks consisting of multiple subnets (e.g., schools), |
parms |
A vector defining the true values of |
lambda |
The true value of the vector |
beta |
The true value of the vector |
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 |
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 |
Value
A list containing:
y |
The simulated variable. |
Gy |
the average of y among friends. |
See Also
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)