qpeer.sim {QuantilePeer} | R Documentation |
Simulating Linear Models with Quantile Peer Effects
Description
qpeer.sim
simulates the quantile peer effect models developed by Houndetoungan (2025).
Usage
qpeer.sim(
formula,
Glist,
tau,
parms,
lambda,
beta,
epsilon,
structural = FALSE,
init,
type = 7,
tol = 1e-10,
maxit = 500,
details = TRUE,
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), |
tau |
The vector of quantile levels. |
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 (see the model specification in the Details section of |
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 |
init |
An optional initial guess for the equilibrium. |
type |
An integer between 1 and 9 selecting one of the nine quantile algorithms used to compute peer quantiles (see the quantile function). |
tol |
The tolerance value used in the Fixed Point Iteration Method to compute the outcome |
maxit |
The maximum number of iterations for the Fixed Point Iteration Method. |
details |
A logical value indicating whether to save the indices and weights of the two peers whose weighted average determines the quantile. |
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. |
qy |
Quantiles of the simulated variable among peers. |
epsilon |
The idiosyncratic error. |
index |
The indices of the two peers whose weighted average gives the quantile. |
weight |
The weights of the two peers whose weighted average gives the quantile. |
iteration |
The number of iterations before convergence. |
References
Houndetoungan, A. (2025). Quantile peer effect models. arXiv preprint arXiv:2405.17290, doi:10.48550/arXiv.2506.12920.
Hyndman, R. J., & Fan, Y. (1996). Sample quantiles in statistical packages. The American Statistician, 50(4), 361-365, doi:10.1080/00031305.1996.10473566.
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
})
tau <- seq(0, 1, 0.25)
X <- cbind(rnorm(n), rpois(n, 2))
l <- c(0.2, 0.1, 0.05, 0.1, 0.2)
b <- c(2, -0.5, 1)
out <- qpeer.sim(formula = ~ X, Glist = G, tau = tau, lambda = l, beta = b)
summary(out$y)
out$iteration