ergm.MSE | R Documentation |
ERGM function to compute marginal substructural effects in ERGM, as described by Duxbury (2025). Intended for use with endogenous substructural terms in ERGMs. Also provides utilities to test interactions between substructural terms and exogenous covariates. See ergm.AME
for average marginal effects and ergm.MEM
for marginal effects at means.
ergm.MSE(model,
substructural_effect,
higher_order_term=NULL,
lower_order_term=NULL,
at.lower_order_term=NULL,
estimate="aMSE",
var2=NULL,
inter=NULL,
at.2=NULL,
at.controls=NULL,
control_vals=NULL,
return_Jac=FALSE)
model |
the model to obtain MSE estimates.Currently accepts |
substructural_effect |
the character string containing the name of the endogenous susbtructural term to use to estimate the MSE. |
higher_order_term |
character string or vector of character strings containing the name(s) of all higher-order endogenous substructures. Optional value. Default value is NULL. |
lower_order_term |
character string or vector of character strings containing the name(s) of all lower-order endogenous substructures. Terms provided will be held at a fixed value as provided with the |
at.lower_order_term |
a vector of numeric values to assign to variables provided in |
estimate |
the type of MSE summary statistic to compute. Should be one of "aMSE", "MSEm","tMSE", or "tMSEm". See details below for information on each estimand. Default is "aMSE" |
var2 |
the character string containing the name of an exogenous variable that interactions with |
inter |
the character string containing the interaction between |
at.2 |
the levels of |
at.controls |
A character string containing the names of all control variables to be specified at fixed levels when calculating the MSE. Should match ERGM output exactly. |
control_vals |
A vector specifying the values to hold at.controls variables. Ignored if at.controls = NULL |
return_Jac |
logical parameter indicating whether to return the Jacobian matrix of parital derivatives used to compute the MSE covariance matrix. Defaults to FALSE. |
Computes the marginal substructural effect for a specified substructural term. Formally, the MSE for a unit is given by
MSE_{ij}=Pr(Y_{ij}=1|-y_{ij},\delta ^+_{ij}(y)=1,x_{ij})-Pr(Y_{ij}=0|-y_{ij},\delta ^+_{ij}(y)=1,x_{ij})
where \delta ^+_{ij}(y)
is the substructural effect of interest. The estimate
argument determines whether the MSE should be taken holding controls at observed values (when set to "aMSE"
), holding controls at means ("MSEm"
), or by combining the estimates from multiple substructures (when set to "aTSE"
).
The terms provided in the lower_order_terms
argument will be held constant at a value of 1 when estimating the MSE, unless alternative values are provided with the at.lower_order_term
argument. If the higher_order_term
argument is provided, the specified term will be held at a value of 0 when estimating the marginal substructural effect
When an endogenous network term is specified as an interaction with an exogenous term, the MSE for each level of the interaction can be obtained by providing the var2
and inter
argumnets. This returns the MSE at different levels of var2
along with a test of the differences between the MSEs. If at.controls and control_vals are provided, the MEM is calculated while holding specified control variables at fixed values provided in control_vals, rather than at their means
A table containing the MSE estimate and variance estimates. If inter
and var2
are provided, a list is returned containing:
change_in_MSE` |
is the change in MSE when the value of |
MSE |
is a table containing MSE estimates, standard errors, and Wald tests for the MSE at each level of |
Syntax is loosely based on the margins package by Thomas Leeper and Stata's margins commands. See ergm.AME to compute average marginal effects. Currently only considers two-ways interactions.
Scott Duxbury, Associate Professor, University of North Carolina–Chapel Hill, Department of Sociology.
Duxbury, Scott W. 2023. "The Problem of Scaling in Exponential Random Graph Models." Sociological Methods & Research.
Duxbury, Scott W., and Jenna Wertsching. 2023. "Scaling Bias in Pooled Exponential Random Graph Models." Social Networks.
Duxbury, Scott W. 2025. "Marginal Substructural Effects for Exponential Random Graph Models." Working Paper.
Long, J. Scott, and Sarah Mustillo. 2018. "Using Predictions and Marginal Effects to Compare Groups in Regression Models for Binary Outcomes." Sociological Methods and Research
Mize, Trenton D. 2019. "Best Practices for Estimating, Interpreting, and Presenting Nonlinear Interaction Effects." Sociological Science
ergm.AME
ergm.mma
ergm.msma
ergm.MEM
margins
library(ergm)
data("faux.dixon.high")
set.seed(21093)
my.ergm<-ergm(faux.dixon.high~edges+
nodeicov("grade")+
nodeocov("grade")+
nodeifactor("sex")+
nodeofactor("sex")+
absdiff("grade")+
nodematch("sex")+
mutual+
gwidegree(.5,fixed=TRUE))
#MSE at means
ergm.MSE(my.ergm,
substructural_effect="mutual",
lower_order_term="gwideg.fixed.0.5",
estimate="MSEm")
#total effect of both endogenous terms
ergm.MSE(my.ergm,
substructural_effect="mutual",
lower_order_term="gwideg.fixed.0.5",
estimate="tMSEm")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.