nwlattice
Generate a lattice network
Syntax
nwlattice
cols rows
,
[undirected
xwrap
ywrap
name(newnetname)
vars(newvarlist)
stub(string)
labs(lab1 lab2 ...)
xvars
ntimes(int)]
cols |
number of columns in lattice; first positional argument |
rows |
number of rows in lattice; default = 1 if omitted |
xwrap |
wrap horizontally |
ywrap |
wrap vertically |
undirected |
generate an undirected network; default = directed |
name(newnetname) |
name of the new network; default = lattice |
vars(newvarlist) |
new variables that are used for the network |
stub(string) |
stub of the variable names when vars() does not give one name per node; default = lattice |
labs(lab1 lab2 …) |
node labels |
xvars |
generate Stata variables for the network |
ntimes(int) |
number of networks to be generated; default = 1 |
noreplace |
reserved; currently a no-op - the create/replace collision guard on name() already applies regardless |
Description
nwlattice generates a lattice network. Each node is connected to maximally four other nodes. With options xwrap and ywrap each node is connected to exactly four other nodes.
Network types
Directed: the default; undirected makes an undirected lattice. Valued: not applicable (the lattice is binary). Two-mode: not applicable (the network is one-mode). Signed: not applicable. See nwnetworktypes.
Examples
. nwclear
. nwlattice 4 4
. nwplot, label(_nodeid)
. nwclear
. nwlattice 4 4, xwrap ywrap
. nwplot, layout(grid) label(_nodeid)
Stored results
-
nwlattice stores the following in r():
- Macros
- r(netlist) — list of new networks
See also
nwcommands version 3.25.0, 14 November 2026 (check your installed version)