homophily.fe: Estimating Network Formation Models with Degree...

View source: R/homophily.fe.R

homophily.feR Documentation

Estimating Network Formation Models with Degree Heterogeneity: the Fixed Effect Approach

Description

homophily.fe implements a Logit estimator for a network formation model with homophily. The model includes degree heterogeneity using fixed effects (see details).

Usage

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
)

Arguments

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 formula should be, for example, ~ x1 + x2, where x1 and x2 are explanatory variables for link formation. If missing, the model is estimated with fixed effects only.

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 environment(formula), typically the environment from which homophily is called.

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 beta, a K-dimensional vector of the explanatory variables' parameters, mu, an n-dimensional vector, and nu, an n-dimensional vector, where K is the number of explanatory variables and n is the number of individuals; or a vector of starting values for c(beta, mu, nu).

method

A character string specifying the optimization method. Expected values are "L-BFGS", "Block-NRaphson", or "Mix". "Block-NRaphson" refers to the Newton-Raphson method applied to each subnetwork, and "Mix" combines the Newton-Raphson method for beta with the L-BFGS method for the fixed effects.

ctr

(optional) A list containing control parameters for the solver. For the optim_lbfgs method from the RcppNumerical package, the list should include maxit.opt (corresponding to maxit for the L-BFGS method), eps_f, and eps_g. For the Block-NRaphson method, the list should include maxit.nr (corresponding to maxit for the Newton-Raphson method) and tol.

print

A boolean indicating if the estimation progression should be printed.

Details

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.

Value

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 optim_lbfgs from the RcppNumerical package.

init

The returned list of starting values.

loglike.init

The log-likelihood at the starting values.

References

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")}.

See Also

homophily.re.

Examples


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)


CDatanet documentation built on April 3, 2025, 11:07 p.m.