Repository navigation
nwcommands 3.22.0
Results that change (read before you re-run old analyses)
nwcontext, mode(either)(ormode(both)) counted a neighbour tied in both directions twice (every neighbour of an undirected network): the sum and the maximum were doubled and the mean was weighted towards the reciprocated neighbours. Each neighbour now counts once, on a valued network with the larger of the two tie values.nwqapwith an attribute term (nwqap y x g) read the attribute by row position, so after the data had been synchronised with a network of another size the attribute could be attached to the wrong nodes (a second identical call gave other coefficients). The data are now synchronised with the dependent network first.nwpathwithego()equal toalter()reports the trivial path of length 0 (r(paths)1,r(path_length)0), as igraph; it reported "not connected".nwpath, generate()on an undirected network stored each tie of the path network in one direction only (an asymmetric matrix flagged undirected); the ties are now stored in both directions.nwbetweenandnwclosenessstore their results as double (float rounded large betweenness scores: 16,834,504 instead of 16,834,503);nwgeodesic, generate(),nwevcent,nwcontextand the coordinates ofnwplot, generate()are double as well.nwplot, layout(grid, columns(1))gave missing x coordinates, and more columns than nodes stopped with a conformability error; both now give a grid.nwexportwrites a binary (unvalued) one-mode network without tie values (Pajek, UCINET DL, GML, edge list: ego and alter only), so thatnwimportreads it back as binary; valued networks are written with their values as before. Before, every exported binary network came back valued.nwtoedge(andnw2toedge) list each tie of a two-mode network with the mode-1 node in_egoand the mode-2 node in_alter, so thatnw2fromedge _ego _alterrebuilds the same network. Before, the node with the higher index was_ego, often the mode-2 node.nwset, labs()andnwfromedge, labs()with fewer labels than nodes give the remaining nodes only default names that are not already used:labs(n2)for 3 nodes gives n2,n4,n3 (before: refused because n2 was repeated). A label repeated inlabs()itself is still refused.nwfromedgewith string identifiers keeps the value of the last row when a pair is listed more than once, as with numeric identifiers (before: the largest value).nwtoedge, numericnumbers ego and alter by the position of the node; before, the numbers were transposed (the row with the value of cell (1,2) had ego 2, alter 1) and did not match the listing of an undirected network.nwsubset netname if a == 1 & b == 2keeps the nodes that meet the whole condition; the condition lost its parentheses, so&and|conditions kept the wrong nodes.nwtranspose b, generate(a) replacetransposed another network whenastood beforebin memory; it transposesbnow.nwreplaceof one cell of an undirected network that leaves the matrix asymmetric marks the network directed (a note says so); before, it stayed undirected with an asymmetric matrix.nwdropnodesandnwkeepnodeskeep the direction of the network; a directed network whose remaining matrix was symmetric became undirected.nwdropnodes, nodes(Bob)on a network with a label containing a blank (e.g. "Anna Maria") dropped another node; labels are looked up exactly now.nwstackof undirected networks gives an undirected network (before: directed).nwuserestores the diagonal of a network with self-loops, and every network comes back exactly as saved: a directed network with a symmetric matrix stays directed (before, it was read as undirected). The data setbaerveldtsaved its ethnicity networks (class<k>_ethn) as directed; it now saves them as undirected, so they load as before. A two-mode network comes back in the node order it was saved in (before: the labels of both modes sorted together). A one-mode network also keeps its saved node order (before: its labels sorted as text,n1 n10 n100 ... n2; for examplenwwebuse mesa). The ties and the node attributes are the same, but everything that depends on the order of the nodes can change: MCMC chains and estimates ofnwergmandnwsaomfor a given seed, random layouts, listings.nwattimereturns the rightr(ties)when a variable namedtiesexists.nwimport, type(ucinet)of an edgelist1 file numbers the nodes by their number, not by their text order (node 10 was node 2 before), and reads a file without tie values as binary.nwset sender receiver value, eventtime(time)with a missing or non-numeric value is refused (r(416), r(109)); before, the value was not used for events.
Added
- Event networks keep the value of each event:
nwset sender receiver value, eventtime(time)stores the third variable per event in the event list (column 4 next to sender, receiver and time); without a value variable every event has the value 1.nwdynamadds the value of an event to the tie, as goldfish does with theincrementof an event. The Mata library is rebuilt (build_eventlist()takes the values as an optional fifth argument).
Fixed
nwdegreeon an undirected network with two names ingenerate()(and noisolates) dropped the variable named second.nwdegree,nwcloseness,nwgeodesic, generate(),nwevcent,nwkatz,nwneighborandnwcontexttreated a variable that merely starts with the requested name as that variable (generate(d)with a variabledlong): the command stopped with r(99), or dropped the other variable.nwevcent, replaceinto an existing byte or integer variable stored truncated values; the variable is now replaced.nwkatz, walkswithoutalpha()stopped with an error on a network without cycles (spectral radius 0); the default alpha is then 1.nwclosenessandnwbetweenwithtwomodeon a one-mode network left a helper network (andnwbetweenthe result variable) behind; the check now comes first. Their helper networks (_tempgeodesic,<net>_symmetrized) have temporary names, so a user network of that name no longer stops the command (nwclosenessstopped with r(99) without a message).nwgeodesic, binary alpha()left the result network behind when it stopped with r(198).nwclustering, symmetrizewithoutgenerate()(or with an invalidmeasure()) left the symmetrized helper network behind, and the next correct call stopped with r(483).nwclustering,nwcliqueandnwbrokerageoverwrote or deleted the user's scalarsclust_global,nw_ncliques,brk_pairsand matrixnw_cliquematrix;nwneighborandnwcontextdeleted the user's Mata objects__nb,__attr,__contextand others;nwcorrelate, attribute()deleted a user network calledsame_<attribute>(it is replaced only withkeepexpand);nwqapstopped with r(483) when a user network_tempexpandexisted. All use temporary names now.nwneighborno longer moves the random-number stream (r(oneneighbor)is drawn with the state restored afterwards).nwpathstops with the error codes ofhelp nwerrorcodes: 485 for a node that does not exist or an id out of range, 483 for a path network that exists, 198 for missing or wrong options (all were r(99)). The message for a missingalter()namedego().nwplot, generate()with one name wrote_x_coordand_y_coord, and overwrote existing variables withoutreplace(and changed their type); it now needs two names andreplaceto overwrite. A network without ties is plotted (its nodes) andgenerate()exports the coordinates; before, nothing was plotted or exported.nwsummarize, detaildid not store the documentedr(missing_edges); it is stored in every case, and the help says what it counts (cells without a value, including the diagonal of a network without self-loops).nwtabulatewith more than two networks said "Network ... not found" (r(482)); it says "Maximum two networks allowed" and stops with r(198).- The help of
nwcontextsays howmax,minandsduse the tie values of a valued network (they are taken over tie value times attribute). nwset, mat() ... replacedropped the existing network before checking the new one: a refused request (wrong shape, repeated labels, wrongvars(), wrongnodenames()) lost it. All checks now come first.vars()of the wrong length no longer leaves a half-made network, andnodenames()of the wrong length or with repeated names is refused (r(198)).nwset, mat() labsfromvar()ignored the variable and used n1, n2, ...; it uses the variable now. A numeric variable is no longer turned into a string.nwset ..., edgelist keeporiginal(andnwimport ..., keeporiginal) stopped with "option keeporiginal not allowed";nwfromedgehas the optionkeeporiginal(variable_nodeoriginalwith the original identifier of each node) and the new optionselfloop(keep the ties of a node with itself).nwfromedge, noclearoverwrote the id variables and dropped rows with a missing identifier; the data are kept as they were.nwfromedge, labs(x y z)(blank-separated, as the help shows) gave one label "x y z"; blanks and commas both separate labels now.nwtoedgeof a network with one node (withcompress, and sonwsaveof such a network or of a two-mode network together with it) stopped with a Mata conformability error and left helper variables in the data.nwtoedge, numericwith several networks is refused before the data are changed.nwsaveandnwusefailed withset varabbrev off("variable _nw_selfloop not found").nwexportmoved_nwincludebehind the user's variables; the variable order is kept, also when the export fails.nwexport, type(ucinet)/nwimport, type(ucinet): the labels were read back as one label; labels with a blank are written in double quotes and read back.nwimport, type(edgelist) nwappendreplaced the data in memory (and cleared them when the file was missing); the data are kept.delimiter()works for edge lists in text files (it stopped with r(6750)).nwrandom, ntimes() nodenamesmata()gave none of the networks the labels;nodenamesmata(),directedandnoreplaceare passed on to every network.- A network name longer than 32 characters (or otherwise not a valid Stata name) was accepted by
nwset,nwfromedge,nwrename,nwgenerate,nwtranspose, generate()andnwpermute, generate(), after which no network could be found ("Network _all not found"). Such names are refused with r(198); the name suggested for a taken name of 31 or 32 characters is shortened to stay within 32. nwset ..., eventtime()stored events with a missing time (sorted last by the event models) and events with a missing sender or receiver (index 0, raw Mata errors later). Such rows are refused with r(416) and a message; nothing is changed.- A command that takes one network, given two (
nwtomata g h, and the event and model commands), said "Network g h not found" (r(482)); it says that only one network is allowed (r(198)). nwexport, type(gml)(andnwtoedge) of a network with exactly one tie stopped with a Mata conformability error.- Error codes follow
help nwerrorcodes: a node label or number that does not exist (nwdropnodes,nwkeepnodes, and the helpers behind them) gives r(485) (was r(6012), r(600021), r(600022), or fornodes(0)a Mata error; a number above the number of nodes was ignored);nwsym, mode()with an invalid value r(6556) (was 6555);nwpermute, generate()andnwstack, name()onto an existing network r(483) (were 99 and 110); other one-off codes became the standard Stata codes for their meaning (198 invalid syntax, 2001 too few observations, 125 out of range, 480 creation failed, 6082/6705 from the list). nwplot ... if/indeleted every user network whose name began with__temp(and one called_temp_in); its helper networks have temporary names now. A wrongedgecolor()/edgesize()sub-option stopped with r(6088) (two-mode unsupported) and could leave a helper network; it stops with r(198).nwdropnodesandnwkeepnodes: a label in a network of 2,000 nodes with long labels stopped with r(1) and no message; node id 0 stopped with a Mata error;generate()left the copy behind when the request was refused.nwsubset x if ..., name(x) replace,nwduplicate x, name(x) replace,nwtranspose x, generate(x) replace,nwpermute x, generate(x) nwreplaceandnwgenerate x = <expression with x>, replace(also when the expression fails) lost the networkx; the old network is now replaced only when the new one exists.nwgenerate y = diffstopped with r(482): the letters "if" inside a network name were taken for anifcondition.nwnoderenameadded a row with the old label and renamed a user variable that had the old label as its name; it renames only the network's own node variable (when the node variables are in the data).nwcollapseleft a network_temp_<name>behind.nwstackstopped with "observation number out of range" when the data had more rows than the stacked network has nodes.nwset ..., twomode(andnw2fromedge) with string identifiers, or a string mode with a numeric one, numbered the nodes in the sort order of both modes together (persons "P1".."P3" and organisations "O1", "O2" gave O1 O2 P1 P2 P3), while the network said that the first three nodes are mode 1: matrices, event lists and the commands built on them mixed the modes up. The mode-1 nodes now come first. A string mode with a numeric one stopped with r(106).- Numeric node identifiers of 10,000,000 or more were turned into labels such as "n1.00e+07" by
nwset ..., eventtime()/time()/interval()and in the mode split ofnwset ..., twomode, while the network's nodes had the full number: events pointed at no node (index 0), two-mode networks put every node in mode 2. Labels are the full number now (also for a numeric identifier paired with a string one innwfromedge). The offset of mode-2 identifiers in a numeric two-mode list is added in double precision.
Tested on macOS with Stata 17 BE, Stata 18 BE and StataNow 19.5 MP (the full test suite) and on Windows 11 with StataNow 19.5 MP. Linux: plugins built by CI, not tested in Stata.