[statnet_help] How to replace network on the right-hand side in
ergm.simulate?
Carter T. Butts
buttsc at uci.edu
Sat Mar 18 20:18:41 PDT 2023
Hi, Ben -
For edgecov, you may find it easier to simply pass a matrix as a
predictor. But more generally, the most flexible thing to do is always
to simply call the simulate command with a formula implementing the
model in lieu of the fitted ergm() object. That way you can change
whatever you like, on the fly, without having to worry about updating
whatever was encoded in the ergm() object.
So, e.g., instead of
mymodel <- ergm(myobsnet ~ edges + edgecov("cardboard") + sunspots)
sim <- simulate(mymodel)
you'd have an expression like
mymodel <- ergm(myobsnet ~ edges + edgecov("cardboard") + sunspots)
sim <- simulate(mynewstartnet ~ edges + edgecov("newcardboard") +
sunspots, coef=coef(mymodel))
where "newcardboard" is whatever you want your covariate to be (could be
the old "cardboard" - reduce, reuse, recycle and all that), and
"mynewstartnet" could be either the network you used to fit the graph or
something else. For instance, in settings where independence of draws
is critical, you might initialize the simulation with e.g. a Bernoulli
graph (produced by rgraph()) with the right target density, and take a
single draw from each chain (being sure to set the burn-in to be long
enough for good convergence). And of course, it is trivial to use the
above as a starting point for adding additional terms to a fitted model
(e.g., for robustness tests).
Another occasionally useful bit of Dark Arts is to coerce your ERGM
formula to a string, manipulate the string, and then coerce the whole
thing back to a formula (thence to use with simulate() or ergm()). I've
used that trick for many things, including to facilitate automated model
comparison/selection. R is very flexible about computing on the
language, which one can use to one's advantage.
Hope that helps,
-Carter
On 3/18/23 12:35 PM, F Benjamin Rosche wrote:
> Dear statnet users,
>
> I have a question regarding the simulate.ergm() function. I fitted an
> ERGM that includes an edge covariate using ergm(g1 ~ edges +
> edgecov(g2, "X") + ...).
>
> To do a counterfactual analysis, I would like to replace g2 with
> another state of this network. While I understand that I can replace
> the network on the left-hand side in simulate.ergm() using
> simulate.ergm(ergm.fit, basis=g1*), I don't know how to replace the
> network on the right-hand side g2 with g2*.
>
> I have noticed that simulate.ergm() does not require g2 to be in the R
> environment - g2 must thus be stored in ergm.fit but the network
> stored in ergm.fit$network seems to be the network on the left-hand side.
>
> Thank you for any pointers that you can provide.
>
> Best wishes,
>
> Ben
> --
> *Benjamin Rosche*
> Cornell University / Social Dynamics Lab / benrosche.com
> <https://urldefense.com/v3/__http://benrosche.com__;!!CzAuKJ42GuquVTTmVmPViYEvSg!NVpfvHx6Ve7mI4BS6f0bokRWD37KA-KYGUMDezJQPYwj8vvcsabCBGEUb8kCuHIPuNZ8nM6m8_O_Ezs$>
>
>
> _______________________________________________
> statnet_help mailing list
> statnet_help at u.washington.edu
> https://urldefense.com/v3/__http://mailman13.u.washington.edu/mailman/listinfo/statnet_help__;!!CzAuKJ42GuquVTTmVmPViYEvSg!NVpfvHx6Ve7mI4BS6f0bokRWD37KA-KYGUMDezJQPYwj8vvcsabCBGEUb8kCuHIPuNZ8nM6mxrbtETI$
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman13.u.washington.edu/pipermail/statnet_help/attachments/20230318/ae59d242/attachment.html>
More information about the statnet_help
mailing list