Description Usage Arguments Details Value References See Also Examples

`sim.IV`

generates Instrument Variables (IV) for linear-in-mean SAR models using only the distribution of the network. See Propositions 1 and 2 of Boucher and Houndetoungan (2020).

1 |

`dnetwork` |
is a square matrix (or a list of matrix if many groups) where the (i, j)th position is the probability of the event "i is linked to j". |

`X` |
is a matrix of the individual observable characteristics. |

`y` |
(optional) is the endogenous variable as a vector. |

`replication` |
(optional, default = 1) is the number of repetitions (see details). |

`power` |
(optional, default = 1) is the number of powers of the interaction matrix used to generate the instruments (see details). |

Bramoullé et al. (2009) show that one can use *GX*, *G^2X*, ..., *G^P X* as instruments for *Gy*, where *P* is the maximal power desired.
`sim.IV`

generate approximation of those instruments, based on Propositions 1 and 2 in Boucher and Houndetoungan (2020) (see also below).
The argument 'power' is the maximal power desired.

When *Gy* and the instruments *GX*, *GGX*, ..., *GG...GX* are not observed,
Boucher and Houndetoungan (2019) show that we can use one drawn from the distribution of the network in order to approximate *Gy*, but that
the same draw should not be used to approximate the instruments. Thus, each component in the function's output gives
'G1y' and 'G1X' computed with the same network and 'G2X' computed with another network, which can be used in order to approximate the instruments.
This process can be replicated several times and the argument 'replication' can be used to set the number of replications desired.

A list of 'replication' components. Each component is a list containing 'G1y' (if the argument 'y' was provided), 'G1X' and 'G2X' where 'G1' and 'G2' are independent draws of network from the distribution (see details).

`G1y` |
is an approximation of |

`G1X` |
is an approximation of |

`G2X` |
is an approximation of |

Boucher, V., & Houndetoungan, A. (2020). Estimating peer effects using partial network data.

Bramoullé, Y., Djebbari, H., & Fortin, B. (2009). Identification of peer effects through social networks. *Journal of econometrics*, 150(1), 41-55. https://www.sciencedirect.com/science/article/abs/pii/S0304407609000335

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 | ```
## Not run:
library(AER)
# Number of groups
M <- 5
# size of the group
N <- 100
# value of lambda (precision parameter for the network formation model)
lambda <- 1
# individual effects
beta <- c(2, 1, 1.5)
# contextual effects
gamma <- c(5, -3)
# endogenous effect
alpha <- 0.4
# std-dev errors
se <- 1
# heterogeneity of the linking probabilities
c <- rnorm(N*N, 0, 1)
# network probabilities
Prob <- list()
for (m in 1:M) {
# heterogeneity of the linking probabilities
c <- rnorm(N*N, 0, 1)
# generate linking probabilities
Pm <- matrix(exp(c / lambda) / (1 + exp(c / lambda)), N)
# no self-link
diag(Pm) <- 0
Prob[[m]] <- Pm
}
# generate data
X <- matrix(data = NA, nrow = 0, ncol = 2)
y <- c()
for (m in 1:M) {
# generate the 'observed network'
Gm <- sim.network(Prob[[m]])
rs <- rowSums(Gm)
rs[rs == 0] <- 1
# row-normalize
Wm <- Gm/rs
# covariates
Xm <- cbind(rnorm(N,0,5),rpois(N,6))
# endogenous variable, no contextual effect
ym <- solve(diag(N) - alpha * Wm) \
y <- c(y, ym)
X <- rbind(X, Xm)
}
# generate instruments
instr <- sim.IV(Prob, X, y, replication = 1, power = 2)
GY1c1 <- instr[[1]]$G1y # proxy for Gy (draw 1)
GXc1 <- instr[[1]]$G1X[,,1] # proxy for GX (draw 1)
G2Xc1 <- instr[[1]]$G1X[,,2] # proxy for GGX (draw 1)
GXc2 <- instr[[1]]$G2X[,,1] # proxy for GX (draw 2)
G2Xc2 <- instr[[1]]$G2X[,,2] # proxy for GGX (draw 2)
# build dataset
# keep only instruments constructed using a different draw than the one used to proxy Gy
dataset <- as.data.frame(cbind(y,X,GY1c1,GXc2,G2Xc2))
# rename variables
colnames(dataset) <- c("y","X1","X2","Gy1","Z1","Z2","ZZ1","ZZ2")
results <- ivreg(y ~ X1 + X2 + Gy1 | X1 + X2 + Z1 + Z2 + ZZ1 + ZZ2, data = dataset)
summary(results)
## End(Not run)
``` |

Embedding an R snippet on your website

Add the following code to your website.

For more information on customizing the embed code, read Embedding Snippets.