ergm.mma: Function to conduct marginal effects mediation analysis in...

View source: R/ergmMMA.R

ergm.mmaR Documentation

Function to conduct marginal effects mediation analysis in ERGM.

Description

ergm.mma is a function to conduct mediation analysis in ERGM using marginal effects. It computes the total, direct, and indirect average marginal effects for two nested ERGMs fit to the same data. 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.mma(restricted.model,full.model,direct.effect,mediator,
                  at.controls=NULL, control_vals=NULL,ME="AME")

Arguments

restricted.model

the ergm without the mediator variable.

full.model

the ergm including the mediator variable.

mediator

a character string containing the name of the mediator variable. When examining joint mediation with multiple mediators, this is a vector with each entry containing the character strings for each mediator variable.

direct.effect

a character string containing the name of the direct effect.

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.

ME

the type of marginal effect to calculate. Currently accepts either "AME" or "MEM". Defaul it "AME"

Details

ergm.mma conducts marginal effects mediation analysis for nested ERGMs fit to the same network by computing the change in average marginal effects between models. The AMEs are estimated on the scale of tie probabilities, not the linear component (log-odds). Standard errors are computed using the Delta method.

A few notes on using ergm.mma:

  • ergm.mma default specification uses the AME, which can be computationally intensive in large networks or high dimensional models. If run times are an issue, try specifying ME="MEM".

  • ergm.mma can be applied to discrete mediators or multiple mediator analysis.

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 effects are computed on the scale of tie probabilities, not the linear component (log-odds).

Note

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

Author(s)

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

References

Duxbury, Scott W. Forthcoming. "The Problem of Scaling in Exponential Random Graph Models." Sociological Methods & Research.

Karlson, Kristian Bernt, Holm, Anders, and Richard Breen. 2012. "Comparing Regression Coefficients Between Same-sample Nested Models Using Logit and Probit: A New Method." Sociological Methodology 42: 286 - 313.

See Also

ergm.AME ergm.mod.mma

Examples




library(ergm)


data("faux.mesa.high")

faux.mesa.high

set.seed(21093)

my.ergm1<-ergm(faux.mesa.high~edges+
            nodecov("Grade")+
            nodefactor("Race")+
            nodefactor("Sex")+
            nodematch("Grade")+
            nodematch("Sex")+
            nodematch("Race"),
            estimate = "MLE")


set.seed(21093)

my.ergm2<-ergm(faux.mesa.high~edges+
                nodecov("Grade")+
                nodefactor("Race")+
                nodefactor("Sex")+
                nodematch("Grade")+
                nodematch("Sex")+
                nodematch("Race")+
               gwesp(.5,fixed=TRUE))


###gwesp as single mediator
ergm.mma(my.ergm1,my.ergm2,mediator="gwesp.fixed.0.5",
             direct.effect="nodecov.Grade")


###multiple mediators

set.seed(21093)

my.ergm3<-ergm(faux.mesa.high~edges+
                 nodecov("Grade")+
                 nodefactor("Race")+
                 nodefactor("Sex")+
                 nodematch("Grade")+
                 nodematch("Sex")+
                 nodematch("Race")+
                 gwdsp(1,fixed=TRUE)+
                 gwesp(.5,fixed=TRUE),
                 #increase MC sample to facilitate convergence
               control = control.ergm(MCMC.samplesize=5000)
)

##joint mediation for gwdsp and gwesp
ergm.mma(my.ergm2,my.ergm3,mediator=c("gwdsp.fixed.1","gwesp.fixed.0.5"),
         direct.effect=names(my.ergm3$coef[8]))



ergMargins documentation built on Nov. 12, 2023, 1:08 a.m.