<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body>
<p>Hi Lin,</p>
<p>A few of us have taken a look at this and still don't have a
clear answer on the behavior or your potential fix. Carter seems
confident it's not an issue in network but something upstream that
calls it. I'm not able to reproduce it. </p>
<p>Are you able to create a minimum reproducible example? Then we
can dive in a lot more deeply.</p>
<p>Thanks,</p>
<p>Steve</p>
<p><br>
</p>
<p><br>
</p>
<div class="moz-cite-prefix">On 8/25/2025 3:05 PM, Zhu, Lin via
statnet_help wrote:</div>
<blockquote type="cite"
cite="mid:DM8PR07MB88084858F753DAEF61116E4E953EA@DM8PR07MB8808.namprd07.prod.outlook.com">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="Generator"
content="Microsoft Word 15 (filtered medium)">
<style>@font-face
{font-family:"Cambria Math";
panose-1:2 4 5 3 5 4 6 3 2 4;}@font-face
{font-family:DengXian;
panose-1:2 1 6 0 3 1 1 1 1 1;}@font-face
{font-family:Aptos;
panose-1:2 11 0 4 2 2 2 2 2 4;}@font-face
{font-family:"\@DengXian";
panose-1:2 1 6 0 3 1 1 1 1 1;}p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0in;
font-size:12.0pt;
font-family:"Aptos",sans-serif;
mso-ligatures:standardcontextual;}.MsoChpDefault
{mso-style-type:export-only;
font-size:10.0pt;
mso-ligatures:none;}div.WordSection1
{page:WordSection1;}</style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
<div class="WordSection1">
<p class="MsoNormal">Dear Statnet community,</p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Hope everyone is doing great! </p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">I’ve been using Statnet for a few years,
and I’m looking to see if anyone had this same error and if it
can be fixed. So in a summary I have had this error
<simpleError in lttails[w2] <- ltheads[w2]: NAs are not
allowed in subscripted assignments> from the
network.extract.with.lasttoggle function since I updated ERGM
from 3.11 to 4.9.0, and TERGM from 3.7.0 to 4.2.2.</p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">I then found that it’s associated with
delete.vertices, which I use to remove nodes when they die. So
only after using this function, simulating nwd again (S3 used
is simulate.networkDynamic) will throw the error. What
happened is that, after deleting the nodes, the ties attached
to them became NULL in mel. And the
network.extract.with.lasttoggle function has the following
code to record edge heads and tails which are further
processed to construct lttails and ltheads (mentioned in the
error message):</p>
<p class="MsoNormal"> valid_eids <- valid.eids(nwd)</p>
<p class="MsoNormal"> tails <- unlist(lapply(nwd$mel,
"[[", "outl"))[valid_eids]</p>
<p class="MsoNormal" style="text-indent:9.75pt">heads <-
unlist(lapply(nwd$mel, "[[", "inl"))[valid_eids]</p>
<p class="MsoNormal">The issue is, lapply(nwd$mel, "[[", "outl")
outputs all vids from mel, including the NULLs. Then
unlist(lapply(nwd$mel, "[[", "outl")) automatically removes
the NULLs and ends up with a shorter vector, making the edges
and indices not matching anymore. Then having the indices
[valid_eids] after and outside of unlist will create NAs at
the end of tails, with the number of NAs equal to the number
of edges that were attached to the removed nodes (the NULL
edges).</p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">A simple fix I think is </p>
<p class="MsoNormal"> tails <- unlist(lapply(nwd$mel,
"[[", "outl")[valid_eids])</p>
<p class="MsoNormal" style="text-indent:9.75pt">heads <-
unlist(lapply(nwd$mel, "[[", "inl") [valid_eids])</p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">However I tried different methods to
replace the code, but it either doesn’t use my updated code,
or R crashes if I edit the tergm namespace or Rprofile. Since
this function is wrapped many layers under simulate, I didn’t
find a better way to replace it.</p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">So has anyone had the same issue? Does my
debugging make sense? If it’s a common issue, would it be
possible to update the function in the package from the
statnet side so it won’t crash? Please feel free to reach out
if you have any questions. Thank you so much for your help!</p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">(A bit more context of the package updates:
I used to use renv to lock the package versions (thanks to
Steve’s suggestion) and had no issues. Recently I got a new
Mac, which cannot install older R versions written with
Rosetta, and renv failed to install the older packages because
the newer R defaults to clang instead of gcc in many places,
which caused a lot of installation errors. I tried to manually
install the packages with no luck. I hence decided to update
my statnet to the new versions.)</p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Best,</p>
<p class="MsoNormal">Lin</p>
</div>
<br>
<fieldset class="moz-mime-attachment-header"></fieldset>
<pre wrap="" class="moz-quote-pre">_______________________________________________
statnet_help mailing list
<a class="moz-txt-link-abbreviated" href="mailto:statnet_help@u.washington.edu">statnet_help@u.washington.edu</a>
<a class="moz-txt-link-freetext" href="http://mailman23.u.washington.edu/mailman/listinfo/statnet_help">http://mailman23.u.washington.edu/mailman/listinfo/statnet_help</a>
</pre>
</blockquote>
<pre class="moz-signature" cols="72">--
******************************************************************************************************
Steven M. Goodreau / Professor, Dept. of Anthropology / Adjunct Prof., Dept. of Epidemiology
(STEE-vun GOOD-roe) / he-him / <a class="moz-txt-link-freetext" href="https://faculty.washington.edu/goodreau">https://faculty.washington.edu/goodreau</a>
Physical address: Denny Hall M236; Mailing address: Campus Box 353100 / 4216 Memorial Way NE
University of Washington / Seattle WA 98195 / dzidzəlalič, x̌ʷəlč
******************************************************************************************************
For there is always light, if only we’re brave enough to see it. If only we’re brave enough to be it.
- Amanda Gorman, The Hill We Climb</pre>
</body>
</html>