ergmMPLE {ergm} | R Documentation |
Return the predictor matrix, response vector, and vector of weights that can be used to calculate the MPLE for an ERGM.
ergmMPLE (formula, fitmodel=FALSE, control=control.ergm(), verbose=FALSE, ...)
formula |
An ergm formula. See |
fitmodel |
Logical: Should the MPLE be found?
If |
control |
A list of control parameters for tuning the fitting of an
ERGM. Most of these parameters are irrelevant in this context.
See |
verbose |
Logical; if |
... |
Additional arguments, to be passed to lower-level functions. |
The MPLE for an ERGM is calculated by first finding the matrix of change
statistics. Each row of this matrix is associated with a particular pair
(ordered or unordered, depending on whether the network is directed
or undirected) of nodes, and the row equals the change in the
vector of network statistics (as defined in formula
) when that
pair is toggled from a 0 (no edge) to a 1 (edge), holding all the rest
of the network fixed. The MPLE results if we perform a logistic
regression in which the predictor matrix is the matrix of change statistics and
the response vector is the observed network (i.e., each entry is either 0 or
1, depending on whether the corresponding edge exists or not).
To save space, the algorithm will automatically search for any duplicated
rows in the predictor matrix (and corresponding response values). Thus,
the ergmMPLE
function will return three items: A response
vector, a predictor matrix, and a vector of weights, which are really counts
that tell how many times each corresponding response, predictor pair is
repeated.
Using fitmodel=FALSE
,
note that the result of the fit may be obtained from the
glm
function, as shown in the examples below.
If fitmodel==FALSE
, a list with three elements, called "response",
"predictor", and "weights". If fitmodel==TRUE
, an object
of class ergm
that gives the fitted pseudolikelihood model.
data(faux.mesa.high) formula <- faux.mesa.high ~ edges + nodematch("Sex") + nodefactor("Grade") mplesetup <- ergmMPLE(formula) # Obtain MPLE coefficients "by hand": glm(mplesetup$response ~ . - 1, data = data.frame(mplesetup$predictor), weights = mplesetup$weights, family="binomial")$coefficients # Check that the coefficients agree with the output of the ergm function: ergmMPLE(formula, fitmodel=TRUE)$coef