Repository navigation
nwcommands 3.23.0
Results that change (read before you re-run old analyses)
- Return codes. A Stata variable that already exists (a
generate()target, for example ofnwdegree,nwbetween,nwcloseness,nwplot,nwgen,nwaltergen) now stops with r(110), Stata's own code for "already defined", in every command; about 40 commands used r(99), which is not a Stata code. Other uses of r(99) now give the code ofhelp nwerrorcodesfor their situation: a network that already exists r(483) (nwgeodesic,nwreach,nwbridges,nwneighbor, subnet()), a node that does not exist or a node id out of range r(485) (nwmaxflow,nwrandomwalk,nwneighbor,nwnode, egoid()),nwnodewithoutego()oregoid()r(198).nwaltergenwith fewer rows of data than nodes gives r(2001) (was r(4)). Do-files that test_rc == 99must be updated. - Temporal networks: a tie observed at several times keeps all of them (see Fixed):
nwattimeof a network declared withtime()orinterval()now returns ties that came and went, which it dropped before;nwsummarizeandnwattimeagree now. nwplot, importcoords()/edgeimport()node size. A node-size slider value saved by the interactive view is now used asnodefactor()itself (a page saved at slider 1 comes back with the default sizes); before it was multiplied by 0.2 and the nodes came back small. An explicitnodefactor()still wins.
Added
nwregularfinds the classes of regularly equivalent nodes (maximal regular equivalence, the CATREGE refinement of Borgatti and Everett 1993 for binary data): nodes are in one class when they send ties to, and receive ties from, the same classes. It stores the class of each node in a variable and returns the number of classes and the image matrix (r(classes),r(image)). New testtest_nwregular.nwegoplotdraws the ego network of one node: ego in the center, the alters on a circle in an order that keeps their ties short (connected groups together, spectral order inside a group),sortby()to group the alters by an attribute,hop(2)for the nodes at distance two on an outer ring. The ties of ego are drawn light and the ties among the others dark, and ego is drawn larger, unlessedgecolor()orsize()are given; all other options go tonwplot. New testtest_nwegoplot.nwbalance ..., reps() seed()compares the share of balanced triads with random signs on the same ties (each tie positive with the observed share of positive ties as probability): mean and standard deviation over the draws, the closed-form expectation, and the number of draws at least as balanced (r(null_mean),r(null_sd),r(null_ge),r(null_expected),r(p_positive),r(reps)). Counts and output withoutreps()are unchanged. New testtest_nwbalance_reps.nwturnover ..., formationcompares the ties formed between the two waves with all pairs without a tie in the first wave: the shares that return a tie of the first wave and that close a two-path of the first wave, in both groups (r(absent),r(formed_recip),r(absent_recip),r(formed_closure),r(absent_closure); for undirected networks only the two-path shares). Counts and output withoutformationare unchanged. New testtest_nwturnover_formation.nwcug ..., stat()short form. Astat()without the##net##placeholder is taken as a command that expects the network as its first argument:stat(nwclustering) rname(cluster_global)isstat(nwclustering ##net##) rname(cluster_global). The placeholder is still needed for a command or program that takes the network elsewhere; calls with it are unchanged.nwclusteringwithoutgenerate()for a one-mode network: the node coefficients then go to a temporary variable, and only the returned results (r(cluster_global),r(cluster_avg)) are kept. A two-mode network still needsgenerate()(orra).
Changed
nwcugandnwcorrelateprint their results the way Stata's own tests do: a header with the network(s), the number of draws (or permutations) and the condition, then a table (nwcug: observed value, mean and standard deviation of the null draws, and the p-values;nwcorrelate: the correlation, and withpermutations()the p-value and the middle 95% of the permuted correlations). The returned results are unchanged.- String variables in categorical options.
nwbrokerage, group(),nwmodularity, group()andnwtabulate, attribute()take a string variable: only whether two nodes share a value matters, so the command runs with the variable encoded (levels in alphabetical order) and the string variable is put back afterwards. Results are the same as with the encoded variable. Before,nwbrokeragerefused strings,nwmodularitysaid the variable had missing values, andnwtabulatestopped with "option matcol() not allowed". The new internal helper_nwstrcat varlist : commanddoes the encoding and restoring, for other commands and the model packages. New testtest_nwstrcat. nwplot ..., labelopt(mlabvposition(varname))places the label of each node at the clock position held in a variable of the node data, for example the first mode of a two-mode network to the left of its column and the second mode to the right. Before, the variable was not found, because the plot is drawn from nwplot's own data. New testtest_nwplot_labpos.
Fixed
nwinstallreports what it could not download. The core is installed in numbered parts; a failed download in the middle used to drop that part and all later ones without a message. Each part is tried twice, andnwinstallstops with r(677) and names the parts that are missing.- Console Stata on macOS (
c(os)is Unix there) finds the macOS plugin and the interactive viewer;animateremoves its files withrmon every non-Windows system. - Interactive viewer (macOS): an unattended export stops at once with a clear message when its window is closed too early, instead of waiting for the time limit.
- Temporal networks: a tie observed at several times keeps all of them.
nwset ..., time()kept one time per pair of nodes, the last row's: a tie listed at waves 1 and 3 was missing fromnwattime ..., at(1), whilenwsummarizestill counted it, so ties could not come and go. The same held forinterval(): a pair with two periods kept only the last. The times are now kept as a list with one entry per row, for one-mode and two-mode networks of any size, andnwattimereturns every tie observed at (or active at) the time asked for. Networks declared by an older version are sliced as before. New testtest_nwattime_multi. nwqaptable: a rounded coefficient, p-value or constant could print with all its binary digits (.9570000000000001instead of.957), which also shifted the p-value column. The values are now formatted before they are shown; stored results are unchanged.nwsummarize ..., save(filename, replace)wrote a file named "filename, replace.dta" and no filename.dta, without a message. The option now takes a file name with an optionalreplace; the file is replaced in either case, as before.nwcontextwith a stringattribute()now stops with an error (r(109)). The statistics use the values as numbers; a string was read as missing and gave an empty variable without a message.nwhomophilywith a string variable counted no observations (summarizeignores strings) and stopped with "Not enough observations". It counts the nonmissing values now, andnwexpandencodes the string as before.nwdendrogramon larger trees. The wheel has one ring for each merge, and every ring was drawn as one plot per group, so that the graph command for a tree of about 50 nodes or more was longer than Stata/BE allows; the error was swallowed, nothing was drawn and nothing was said. With one color and one symbol (the default) each kind of element is now one plot, which draws the same picture (identical for small trees), and the 71 lawyers oflazegadraw in Stata/BE.colorpalette()andsymbolpalette()were passed on nested and failed the same silent way; they work now. New testtest_nwdendrogram_large.help nwerrorcodeslists every code the core commands raise, the package-specific codes and the Stata codes, with the situations in which each is raised. It said it documented every code but listed only the package-specific ones, and it listed r(481), which no command raises (Stata uses 481 for another error).- Website command reference: sections of the help files with other titles than the standard ones were left out of the web pages, among them "Network types" (129 commands), "Limits" (83 commands), the code tables of
nwerrorcodes, the data set descriptions ofnwwebuseand most ofnwintroandnwprogramming. All sections are now converted.
Tested on macOS with Stata 17 BE, Stata 18 BE and StataNow 19.5 MP (the full test suite), on Windows 11 with StataNow 19.5 MP and on Linux (Ubuntu 22.04) with StataNow 19.5 MP. On Linux, in console Stata, the tests that need the Stata GUI (dialogs, nwinstall, usermenu, view) cannot run and are not counted.