Installing nwsbm

nwsbm is a separate package (GPL-3) that needs the core nwcommands (3.28.0 or later). Install the core first, then nwsbm.

1. The core

. net install nwcommands, from(https://nwcommands.org/net/) replace
. nwinstall, everything

nwinstall, everything installs the core and all seven model packages in one step; nwinstall, all installs the core only.

See Installation & Setup for details, including computers without internet access or administrator rights.

2. nwsbm

. nwinstall, models

If you used nwinstall, everything above, the model packages are already installed; after nwinstall, all (core only) add them with nwinstall, models. Repeating either command updates them. To install nwsbm only, use its own address:

. net install nwsbm, from(https://raw.githubusercontent.com/thomas-u-grund/nwsbm/main/)

(nwinstall, modelpkg(nwsbm) does the same from the core.)

A specific release

Every release is tagged on GitHub and each tag has its own address. For version 1.0.2:

. net install nwsbm, from(https://raw.githubusercontent.com/thomas-u-grund/nwsbm/v1.0.2/) replace

Use a tagged release when you want an analysis to be reproducible: you can then say exactly which version produced the results.

3. Check the installation

. nwsbm version
nwsbm version 1.0.2, 20nov2026
  native plugin           : .../s/sbm_vem_macos.plugin (ships with the package)
  reference               : R packages blockmodels, sbm and greed
  license                 : GNU GPL-3

The output shows the release of nwsbm and the native plugin in use. The release is stored in r(version); quote it when you report an analysis. nwversion lists the core and all installed model packages. help nwsbm opens the complete documentation.

Without internet access

On a computer without internet access, install from zip files. Download the nwsbm zip and the nwcommands zip elsewhere, unzip them, rename the unzipped nwsbm-main folder to nwsbm, and run nwinstall, localcopy all in the core folder followed by nwinstall, modelpkg(nwsbm) modelsfrom("<folder that holds nwsbm>"). The steps, with all the zip files, are on the installation page of the core.

Updating

Repeat the net install line with replace. Updating the core never overwrites nwsbm, and updating nwsbm never changes the core. net describe nwsbm shows the installed version and distribution date.

The native plugin

The package ships a compiled plugin for macOS, Linux and Windows. It is installed together with the package and found automatically; nothing needs to be configured. The variational EM runs in the plugin; the tables and the post-estimation commands are Stata code. There is no slower fallback: without a working plugin nwsbm stops with an error that names the plugin. threads(#) sets the number of threads (default one per core); the result does not depend on the number of threads.

If the plugin does not work on your computer

If the plugin of your platform is missing, older than the .ado files, or does not load on your system, compile it on your own computer:

. nwinstall, buildplugin(nwsbm)

The command fetches the C source of the package from its GitHub repository, compiles it with the compiler of your computer and installs the plugin where net install puts it (an existing file is kept with the extension .prev). You need a C compiler, installed once: on a Mac the command line tools of Xcode (xcode-select --install in the Terminal), on Linux gcc and make, on Windows Microsoft’s free Build Tools for Visual Studio with the workload Desktop development with C++; if the compiler is missing, the command says what to install. Restart Stata afterwards. A plugin depends on the operating system and the processor, not on the version or the flavour of Stata (BE, SE, MP). The source is free software (GPL-3) and is in the folder native/ of the repository.

Rebuilding the Mata library on your own computer

The Mata libraries of the packages are built with Stata 17. A library built by an older Stata loads in every later Stata, but a library built by a newer Stata is ignored by an older one (every Mata function is then “not found”, r(3499)). If that happens, build the library with your own Stata:

. nwinstall, buildmata(nwsbm)

The build clears the data and the Mata objects in memory (save first), and it takes a few minutes. Update the packages first, because the source of the current release is used. Restart Stata afterwards.

Requirements

  • Stata 17 or later; Stata/BE is enough. Tested on macOS with Stata 17, 18 and 19, and on Linux and Windows with Stata 19 (the Mata libraries are built with Stata 17, the oldest tested version; Stata 16 and older are untested).
  • The core nwcommands, as above. No R and no other software.

Next

The tutorial fits a first block model.


Back to top

nwcommands is free software under the GNU General Public License, version 3, as are the model packages nwsaom, nwergm, nwdynam, nwrem, nwalaam, nwlsm and nwsbm. Citing and licenses · Get help · GitHub. Issues with the core go to the nwcommands repository; issues with a model package go to that package's own repository.

This site uses Just the Docs, a documentation theme for Jekyll.