homophily.fe | R Documentation |
homophily.fe
implements a Logit estimator for a network formation model with homophily. The model includes degree heterogeneity using fixed effects (see details).
homophily.fe(
network,
formula,
data,
symmetry = FALSE,
fe.way = 1,
init = NULL,
method = c("L-BFGS", "Block-NRaphson", "Mix"),
ctr = list(maxit.opt = 10000, maxit.nr = 50, eps_f = 1e-09, eps_g = 1e-09, tol = 1e-04),
print = TRUE
)
network |
A matrix or list of sub-matrices of social interactions containing 0 and 1, where links are represented by 1. |
formula |
An object of class formula: a symbolic description of the model. The |
data |
An optional data frame, list, or environment (or object coercible by as.data.frame to a data frame) containing the variables
in the model. If not found in data, the variables are taken from |
symmetry |
Indicates whether the network model is symmetric (see details). |
fe.way |
Indicates whether it is a one-way or two-way fixed effect model. The expected value is 1 or 2 (see details). |
init |
(optional) Either a list of starting values containing |
method |
A character string specifying the optimization method. Expected values are |
ctr |
(optional) A list containing control parameters for the solver. For the |
print |
A boolean indicating if the estimation progression should be printed. |
Let p_{ij}
be the probability for a link to go from individual i
to individual j
.
This probability is specified for two-way effect models (fe.way = 2
) as
p_{ij} = F(\mathbf{x}_{ij}'\beta + \mu_i + \nu_j),
where F
is the cumulative distribution function of the standard logistic distribution. Unobserved degree heterogeneity is captured by
\mu_i
and \nu_j
. These are treated as fixed effects (see homophily.re
for random effect models).
As shown by Yan et al. (2019), the estimator of the parameter \beta
is biased. A bias correction is necessary but not implemented in this version. However,
the estimators of \mu_i
and \nu_j
are consistent.
For one-way fixed effect models (fe.way = 1
), \nu_j = \mu_j
. For symmetric models, the network is not directed, and the fixed effects need to be one-way.
A list consisting of:
model.info |
A list of model information, such as the type of fixed effects, whether the model is symmetric, the number of observations, etc. |
estimate |
The maximizer of the log-likelihood. |
loglike |
The maximized log-likelihood. |
optim |
The returned value from the optimization solver, which contains details of the optimization. The solver used is |
init |
The returned list of starting values. |
loglike.init |
The log-likelihood at the starting values. |
Yan, T., Jiang, B., Fienberg, S. E., & Leng, C. (2019). Statistical inference in a directed network model with covariates. Journal of the American Statistical Association, 114(526), 857-868, \Sexpr[results=rd]{tools:::Rd_expr_doi("https://doi.org/10.1080/01621459.2018.1448829")}.
homophily.re
.
set.seed(1234)
M <- 2 # Number of sub-groups
nvec <- round(runif(M, 20, 50))
beta <- c(.1, -.1)
Glist <- list()
dX <- matrix(0, 0, 2)
mu <- list()
nu <- list()
Emunu <- runif(M, -1.5, 0) # Expectation of mu + nu
smu2 <- 0.2
snu2 <- 0.2
for (m in 1:M) {
n <- nvec[m]
mum <- rnorm(n, 0.7*Emunu[m], smu2)
num <- rnorm(n, 0.3*Emunu[m], snu2)
X1 <- rnorm(n, 0, 1)
X2 <- rbinom(n, 1, 0.2)
Z1 <- matrix(0, n, n)
Z2 <- matrix(0, n, n)
for (i in 1:n) {
for (j in 1:n) {
Z1[i, j] <- abs(X1[i] - X1[j])
Z2[i, j] <- 1*(X2[i] == X2[j])
}
}
Gm <- 1*((Z1*beta[1] + Z2*beta[2] +
kronecker(mum, t(num), "+") + rlogis(n^2)) > 0)
diag(Gm) <- 0
diag(Z1) <- NA
diag(Z2) <- NA
Z1 <- Z1[!is.na(Z1)]
Z2 <- Z2[!is.na(Z2)]
dX <- rbind(dX, cbind(Z1, Z2))
Glist[[m]] <- Gm
mu[[m]] <- mum
nu[[m]] <- num
}
mu <- unlist(mu)
nu <- unlist(nu)
out <- homophily.fe(network = Glist, formula = ~ -1 + dX, fe.way = 2)
muhat <- out$estimate$mu
nuhat <- out$estimate$nu
plot(mu, muhat)
plot(nu, nuhat)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.