| simSAR | R Documentation |
simSAR simulates linear peer effect models.
simSAR(formula, Glist, parms, lambda, beta, epsilon, nthreads = 1, data)
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. |
nthreads |
A strictly positive integer indicating the number of threads to use. |
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 |
A list containing:
y |
The simulated variable. |
Gy |
the average of y among friends. |
smmSAR, mcmcSAR
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 <- simSAR(formula = ~ X, Glist = G, lambda = l, beta = b)
summary(out$y)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.