add_node {simDAG} | R Documentation |
Add a DAG.node
object to a DAG
object
Description
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
.
Usage
add_node(dag, node)
## S3 method for class 'DAG'
object_1 + object_2
Arguments
dag |
A |
node |
A |
object_1 |
Either a |
object_2 |
See argument |
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.
Value
Returns an DAG
object with the DAG.node
object added to it.
Author(s)
Robin Denz
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))