ergm.msma: Function to compare marginal substructrual effects between...

View source: R/ergm.MSMA.R

ergm.msmaR Documentation

Function to compare marginal substructrual effects between nested ERGMs.

Description

ergm.msmsa tests the difference in a marginal substructural effect between two ERGMs fit to the same network that differ only in their specification. It computes the total, direct, and indirect marginal substructural effects. Can be used with discrete or continuous mediators and for multiple mediator analyses. Currently accepts ergm, btergm, mtergm, ergm.count, mlergm, and ergm.multi objects.

Usage

ergm.msma(restricted.model,
                    full.model,
                    direct_substructural_effect,
                    higher_order_term=NULL,
                    lower_order_term=NULL,
                    at.lower_order_term=NULL,
                    mediator,
                    at.controls=NULL,
                    control_vals=NULL,
                    estimate="aMSE")

Arguments

restricted.model

the ergm without the mediator variable.

full.model

the ergm including the mediator variable.

direct_substructural_effect

a character string identifying to the marginal substructural effect to be compared between models

higher_order_term

an optional parameter identifying any higher-order substructures to be held at 0 when calculating marginal substructural effects. higher_order_term must appear in both models when specified

lower_order_term

an optional parameter identifying lower-order substructures nested in direct_substructural_effect. When provided, the lower-order terms will be held at fixed values calculating direct and indirect marginal substructural effects

at.lower_order_term

optional parameter identifying the values to assign to lower_order_term. Should be provided as a vector of numeric values with each entry corresponding to a single entry in lower_order_term. Default is 1

mediator

a character string containing the name of the mediator variable. Can be specified as a vector with each entry containing the character strings for several mediator variables when there are multiple mediators.

at.controls

a vector of character strings containing the names of control variables to hold at prespecified values.

control_vals

a vector of numeric values to hold at.controls at during estimation.

estimate

the type of marginal substructural effect to calculate. Must be one of "aMSE", "MSEm","tMSE", or "tMSEm"

Details

ergm.msma calculates the change in a marginal substructural effect between two models fit to the same data. Formally, define two models Mod^1 and Mod^2 that differ by the inclusion of one or more mediating variables. For a substructural network term of interest given by the change statistic \delta ^+_{ij}(y), the ergm.msma provides the following quantities:

MSE^{Mod^1}(\delta ^{+}_{ij}(y))

MSE^{Mod^2}(\delta ^{+}_{ij}(y))

MSE^{Mod^1}(\delta ^{+}_{ij}(y))-MSE^{Mod^2}(\delta ^{+}_{ij}(y))

Where MSE^{Mod^1}(\delta ^{+}_{ij}(y)) is the total effect corresponding to the marginal substructural effect of \delta ^{+}_{ij}(y) operating through all indirect pathways, MSE^{Mod^2}(\delta ^{+}_{ij}(y)) is the direct effect of \delta ^+_{ij}(y) on tie formation, and MSE^{Mod^1}(\delta ^{+}_{ij}(y))-MSE^{Mod^2}(\delta ^{+}_{ij}(y)) is the portion of the total effect explained by controlling for a confounding variable.

Value

Returns a table including the point estimates and standard errors for total, direct, and indirect effects. A single indirect effect is reported for joint mediation analyses. All marginal substructural effects are computed on the scale of tie probabilities, not the linear component (log-odds).

Note

Note that ergm.msma may have restrictive run times in large networks or high dimensional models.

Author(s)

Scott Duxbury, Associate Professor, University of North Carolina–Chapel Hill, Department of Sociology.

References

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.

See Also

ergm.AME ergm.mod.mma ergm.mma ergm.MSE ergm.MEM

Examples




library(ergm)


data("faux.mesa.high")

faux.mesa.high

#does homophily explain triadic effects?

  #model without homophily
my.ergm1<-ergm(faux.mesa.high~edges+
                nodematch("Grade")+
                nodematch("Sex")+
                nodematch("Race")+
                gwesp(.5,fixed=TRUE),
               control = control.ergm(MCMLE.termination="Hummel",
                                      MCMLE.effectiveSize = NULL,
                                      MCMC.samplesize = 5000,
                                      MCMLE.maxit=120))


  #model with homophily
my.ergm2<-ergm(faux.mesa.high~edges+
                nodecov("Grade")+
                nodefactor("Race")+
                nodefactor("Sex")+
                nodematch("Grade")+
                nodematch("Sex")+
                nodematch("Race")+
                 gwesp(.5,fixed=TRUE),
                control = control.ergm(MCMLE.termination="Hummel",
                                      MCMLE.effectiveSize = NULL,
                                      MCMC.samplesize = 5000,
                                      MCMLE.maxit=120))


###gwesp as single mediator
ergm.msma(my.ergm1,
            my.ergm2,
            direct_substructural_effect="gwesp.fixed.0.5",
            mediator=c("nodematch.Grade","nodematch.Sex","nodematch.Race"),
            estimate="aMSE")





ergMargins documentation built on April 11, 2025, 5:40 p.m.