<html xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="Generator" content="Microsoft Word 15 (filtered medium)">
<style><!--
/* Font Definitions */
@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:Consolas;
panose-1:2 11 6 9 2 2 4 3 2 4;}
@font-face
{font-family:"\@DengXian";
panose-1:2 1 6 0 3 1 1 1 1 1;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0in;
font-size:12.0pt;
font-family:"Aptos",sans-serif;}
a:link, span.MsoHyperlink
{mso-style-priority:99;
color:blue;
text-decoration:underline;}
pre
{mso-style-priority:99;
mso-style-link:"HTML Preformatted Char";
margin:0in;
font-size:10.0pt;
font-family:"Courier New";}
span.HTMLPreformattedChar
{mso-style-name:"HTML Preformatted Char";
mso-style-priority:99;
mso-style-link:"HTML Preformatted";
font-family:"Consolas",serif;}
span.EmailStyle23
{mso-style-type:personal-reply;
font-family:"Aptos",sans-serif;
color:windowtext;}
.MsoChpDefault
{mso-style-type:export-only;
font-size:10.0pt;
mso-ligatures:none;}
@page WordSection1
{size:8.5in 11.0in;
margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
{page:WordSection1;}
--></style>
</head>
<body lang="EN-US" link="blue" vlink="purple" style="word-wrap:break-word">
<div class="WordSection1">
<p class="MsoNormal">Hi Steve and statnet team,<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Thank you so much for your help! I really appreciate it!<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">I have coded a simple example (attached), and attached the initial dynamic network and the fitted STERGM to be used in the example. Please let me know if you can replicate the error or have any questions. Thanks a lot!!<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Best,<o:p></o:p></p>
<p class="MsoNormal">Lin<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<div id="mail-editor-reference-message-container">
<div>
<div>
<div style="border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0in 0in 0in">
<p class="MsoNormal" style="margin-bottom:12.0pt"><b><span style="color:black">From:
</span></b><span style="color:black">Steven M. Goodreau <goodreau@uw.edu><br>
<b>Date: </b>Monday, September 15, 2025 at 7:26</span><span style="font-family:"Arial",sans-serif;color:black"> </span><span style="color:black">PM<br>
<b>To: </b>Zhu, Lin <l.zhu3@med.miami.edu>, statnet_help@u.washington.edu <statnet_help@u.washington.edu><br>
<b>Subject: </b>[EXTERNAL] Re: [statnet_help] Issue with delete.vertices and network.extract.with.lasttoggle<o:p></o:p></span></p>
</div>
<div>
<div align="center">
<table class="MsoNormalTable" border="0" cellspacing="4" cellpadding="0" width="100%" style="width:100.0%">
<tbody>
<tr>
<td style="background:black;padding:.75pt .75pt .75pt .75pt">
<table class="MsoNormalTable" border="0" cellspacing="0" cellpadding="0" width="100%" style="width:100.0%">
<tbody>
<tr>
<td style="background:#FEC7CE;padding:7.5pt 7.5pt 7.5pt 7.5pt">
<p class="MsoNormal" align="center" style="text-align:center"><strong><span style="font-family:"Arial",sans-serif;color:#91040B">CAUTION:</span></strong><span style="font-family:"Arial",sans-serif;color:#91040B">
</span><span style="font-family:"Arial",sans-serif;color:black">This email originated from outside the organization.
<strong><span style="font-family:"Arial",sans-serif">DO NOT CLICK ON LINKS</span></strong>
<u>or</u> <strong><span style="font-family:"Arial",sans-serif">OPEN ATTACHMENTS</span></strong> unless you know and trust the sender.</span><o:p></o:p></p>
</td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<p>Hi Lin,<o:p></o:p></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. <o:p></o:p></p>
<p>Are you able to create a minimum reproducible example? Then we can dive in a lot more deeply.<o:p></o:p></p>
<p>Thanks,<o:p></o:p></p>
<p>Steve<o:p></o:p></p>
<p><o:p> </o:p></p>
<p><o:p> </o:p></p>
<div>
<p class="MsoNormal">On 8/25/2025 3:05 PM, Zhu, Lin via statnet_help wrote:<o:p></o:p></p>
</div>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<div>
<p class="MsoNormal">Dear Statnet community,<o:p></o:p></p>
<p class="MsoNormal"> <o:p></o:p></p>
<p class="MsoNormal">Hope everyone is doing great! <o:p></o:p></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.<o:p></o:p></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):<o:p></o:p></p>
<p class="MsoNormal"> valid_eids <- valid.eids(nwd)<o:p></o:p></p>
<p class="MsoNormal"> tails <- unlist(lapply(nwd$mel, "[[", "outl"))[valid_eids]<o:p></o:p></p>
<p class="MsoNormal" style="text-indent:9.75pt">heads <- unlist(lapply(nwd$mel, "[[", "inl"))[valid_eids]<o:p></o:p></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).<o:p></o:p></p>
<p class="MsoNormal"> <o:p></o:p></p>
<p class="MsoNormal">A simple fix I think is <o:p></o:p></p>
<p class="MsoNormal"> tails <- unlist(lapply(nwd$mel, "[[", "outl")[valid_eids])<o:p></o:p></p>
<p class="MsoNormal" style="text-indent:9.75pt">heads <- unlist(lapply(nwd$mel, "[[", "inl") [valid_eids])<o:p></o:p></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.<o:p></o:p></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!<o:p></o:p></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.)<o:p></o:p></p>
<p class="MsoNormal"> <o:p></o:p></p>
<p class="MsoNormal">Best,<o:p></o:p></p>
<p class="MsoNormal">Lin<o:p></o:p></p>
</div>
<p class="MsoNormal"><br>
<br>
<o:p></o:p></p>
<pre>_______________________________________________<o:p></o:p></pre>
<pre>statnet_help mailing list<o:p></o:p></pre>
<pre><a href="mailto:statnet_help@u.washington.edu">statnet_help@u.washington.edu</a><o:p></o:p></pre>
<pre><a href="https://urldefense.com/v3/__http:/mailman23.u.washington.edu/mailman/listinfo/statnet_help__;!!KVu0SnhVq1hAFvslES2Y!PnYvP4AXoCjRAJ5Qsck3dQcCQrzO93AXbtTABPkRJTRTttTVtEzLzDMDIYMfJ-hRlz05eYPeFNx8MvqIviAeTw$">http://mailman23.u.washington.edu/mailman/listinfo/statnet_help</a> <o:p></o:p></pre>
</blockquote>
<pre>-- <o:p></o:p></pre>
<pre>******************************************************************************************************<o:p></o:p></pre>
<pre>Steven M. Goodreau / Professor, Dept. of Anthropology / Adjunct Prof., Dept. of Epidemiology<o:p></o:p></pre>
<pre>(STEE-vun GOOD-roe) / he-him / <a href="https://urldefense.com/v3/__https:/faculty.washington.edu/goodreau__;!!KVu0SnhVq1hAFvslES2Y!PnYvP4AXoCjRAJ5Qsck3dQcCQrzO93AXbtTABPkRJTRTttTVtEzLzDMDIYMfJ-hRlz05eYPeFNx8MvoNvdfoSA$">https://faculty.washington.edu/goodreau</a> <o:p></o:p></pre>
<pre>Physical address: Denny Hall M236; Mailing address: Campus Box 353100 / 4216 Memorial Way NE<o:p></o:p></pre>
<pre>University of Washington / Seattle WA 98195 / dzidzəlalič, x̌ʷəlč<o:p></o:p></pre>
<pre>******************************************************************************************************<o:p></o:p></pre>
<pre>For there is always light, if only we’re brave enough to see it. If only we’re brave enough to be it.<o:p></o:p></pre>
<pre>- Amanda Gorman, The Hill We Climb<o:p></o:p></pre>
</div>
</div>
</div>
</div>
</body>
</html>