How it works:
Internally the following procedure is used whenever a net() function call is included in a formula of a node (regardless of whether time-fixed or time-dependent). First, the associated network (defined using the net argument) is used to identify the neighbors of each observation. Every vertex that is directly connected to an observation is considered its' neighbor. The parent variable(s) specified in the net() call are then aggregated over these neighbors using the given expr. A simple example: consider observation 1 with four neighbors named 2, 5, 8 and 10. The formula contains the following net() call: net(sum(infected)). The value of the infected variable is 0, 0, 1, 1 for persons 2, 5, 8 and 10 respectively. These values are then summed up to result in a value of 2 for person 1. The same is done for every person in the simulated data. The resulting variable is then used as-is in the simulation.
Supported inputs:
Any function that returns a single (usually numeric) value, given the neighbors' values can be used. It is therefore also possible to make the simulation dependent on specific neighbors only. For example, using infected[1] instead of sum(infected) would return a value of 0 for observation 1 in the above example, because person 2 is the first neighbor and has a value of 0. Note that the internally used variable named ..neighbor.. includes the ids of the neighbors. The entire expr is evaluated in a data.table call of the form: data[, .(variable = eval(expr)), by=id], making it also possible to use any data.table syntax such as .N (which would return the number of neighbors a person has).
Specifying parents:
Whenever a net() call is used in a formula, we recommend specifying the parents argument of the node as well. The reason for this recommendation is, that it is sometimes difficult to identify which variables are used in net() calls, depending on the expr. This may cause issues if a DAG is not specified in a topologically sorted manner and users rely on the sort_dag argument of sim_from_dag to re-order the variables. Specifying the parents ensures that this issue cannot occur.
A small warning:
Note that it never really makes sense to use this function outside of a formula argument: if you look at its source code you will realize that it does not actually do anything, except returning its input. It is only a piece of syntax for the formula interface. Please consult the network documentation page or the associated vignette for more information.