# NOT RUN {
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, output="fit")$coef
# We can also format the predictor matrix into an array:
mplearray <- ergmMPLE(formula, output="array")
# The resulting matrices are big, so only print the first 5 actors:
mplearray$response[1:5,1:5]
mplearray$predictor[1:5,1:5,]
mplearray$weights[1:5,1:5]
formula2 <- faux.mesa.high ~ gwesp(0.5,fix=FALSE)
# The term is treated as fixed: only the gwesp term is returned:
colnames(ergmMPLE(formula2, as.initialfit=TRUE)$predictor)
# The term is treated as curved: individual esp# terms are returned:
colnames(ergmMPLE(formula2, as.initialfit=FALSE)$predictor)
# }
Run the code above in your browser using DataLab