Add a DAG.node
object to a DAG
object
add_node.Rd
This function allows users to add DAG.node
objects created using the node
or node_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
.
Details
The two ways of adding a node 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.
Examples
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))