gbme - R-functions for statistical analysis of social network data
gbme is a set of R functions
that fit generalized bilinear mixed effects models to dyadic and network
data, as described in Hoff(2003).
It provides a Markov-chain Monte Carlo estimation procedure for
Gaussian, Poisson, and logistic regression models with fixed
and random effects.
If you find this code slow or clunky, please try instead
the following software:
- eigenmodel, an R-package for latent factor analysis of symmetric, ordinal network data;
- svdmodel,
R-code for latent factor analysis of asymmetric, ordinal network data.
These packages do nearly the same thing as gbme, but run much faster.
NEW: gbme.asym.r This is a hacked
version of gbme.r, providing asymmetric inner-product effects
u'v instead of z'z. The u's and v's are sender- and receiver-specific
multiplicative
effects, respectively.
This is a more general model, and is more appropriate for data where
there might be an aversion to transitivity. Take a look at
Ward and Hoff(2005)
for an example application.
- Usage: gbme(Y,Xd,Xs,Xr,...)
- Data arguments:
- Y is a square (nxn) sociomatrix. Missing (at random) data is allowed.
- Xd is an nxnxrd array giving dyad-specific covariates.
- Xs is an nxrs matrix of sender-specific covariates.
- Xr is an nxrr matrix of receiver-specific covariates.
- Model specification arguments (defaults in parentheses):
- family ("gaussian") : can be "gaussian", "poisson" or "binomial"
- directed (T) : logical denoting if the relation is directed or
not. If directed=F, the algorithm assumes Y and Xd are
symmetric.
- k (0) : an integer denoting the dimension of the inner-product interaction
- Prior probability arguments: empirical Bayes priors are used if nothing
is provided
- Starting values: MCMC starts from an approximate IRLS solution if
nothing is provided
- Output: By default, samples of the parameters and latent
characteristics are output to files "OUT" and "Z". Each row of
"OUT" is as follows:
- k (length 1)
- the mcmc iteration number (length 1)
- the (saturated) log-likelihood (length 1)
- the dyadic-level regression coefficients (length rd)
- the intercept (length 1)
- the sender-level regression coefficients (length rs)
- the receiver-level regression coefficients (length rr)
- entries [1,1], [1,2], [2,2] of the covariance matrix of a's and b's
- variance of the epsilons (length 1)
- correlation of e_ij and e_ji (length 1)
- variances of the k components of the z vectors (length k)
The file "Z" consists of NS/odens matrices of dimension
nxk put end to end, where NS/odens is the number of
saved values of Z (default is 100000/50).
Installation: Download the text file
gbme.r.
Start an R-session with gbme.r in the directory and type
source("gbme.r")
Alternatively, if you don't want to download the file, just
type
source("http://www.stat.washington.edu/hoff/Code/GBME/gbme.r")
Running the MCMC may take a long time, so you might want to
do it in batch mode.
Some ideas for a simple analysis of the output is
given in
gbme.postana.r.
You might want to look at the following examples:
Feedback: Let me know if you use this package, have suggestions,
or encounter bugs. The more feedback I get, the more I will feel
compelled to improve the software.
email: hoff@stat.washington.edu