| add_node | R Documentation | 
DAG.node or a DAG.network object to a DAG object
This function allows users to add DAG.node objects created using the node or node_td function and DAG.network objects created using the network or network_td function to DAG objects created using the empty_dag function, which makes it easy to fully specify a DAG to use in the sim_from_dag function and sim_discrete_time.
add_node(dag, node)
## S3 method for class 'DAG'
object_1 + object_2
| dag | A  | 
| node | Either a  | 
| object_1 | Either a  | 
| object_2 | See argument  | 
The two ways of adding a node or a network to a DAG object are: dag <- add_node(dag, node(...)) and dag <- dag + node(...), which give identical results (note that the ... should be replaced with actual arguments and that the initial dag should be created with a call to empty_dag). See node for more information on how to specify a DAG for use in the sim_from_dag and node_td functions.
Returns an DAG object with the DAG.node object or DAG.network object added to it.
Robin Denz
library(simDAG)
## add nodes to DAG using +
dag <- empty_dag() +
  node("age", type="rnorm", mean=50, sd=5) +
  node("sex", type="rbernoulli", p=0.5) +
  node("income", type="gaussian", parents=c("age", "sex"), betas=c(1.1, 0.2),
       intercept=-5, error=4)
## add nodes to DAG using add_node()
dag <- empty_dag()
dag <- add_node(dag, node("age", type="rnorm", mean=50, sd=5))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.