| set_lazy_dag | R Documentation |
DAG object from a lazy_DAG object
Given a un-evaluated lazy_DAG object, created using the lazy_dag function and a named list or vector of parameters, this function returns a fully specified DAG object that can then be used to run actual simulations using sim_from_dag, sim_discrete_time or sim_discrete_event. See details and ?lazy_dag for more information.
set_lazy_dag(lazy_dag, params)
lazy_dag |
A |
params |
A named list or a named vector, containing one entry per |
Given the previously un-evaluated lazy_DAG object, this function substitutes all param() pieces with the corresponding parameter defined in params and then finally evaluates the DAG. Note that the lazy_DAG object itself is not changed in place, so that the set_lazy_dag() function may be used multiple times on the same lazy_DAG to create multiple different data generation processes.
Returns a DAG object.
Robin Denz
library(simDAG)
# define a lazy DAG with one unspecified parameter
ldag <- lazy_dag(
empty_dag() +
node("A", type="rnorm", mean=1, sd=param(SD))
)
# get a real DAG object with SD = 1 and another with SD = 2
dag1 <- set_lazy_dag(ldag, params=c(SD=1))
dag2 <- set_lazy_dag(ldag, params=c(SD=2))
# define some lazy DAG, leaving the intercept of "death" and one beta
# coefficient of "smoking" unspecified
ldag <- lazy_dag(
empty_dag() +
node("age", type="rnorm", mean=10, sd=2) +
node("sex", parents="", type="rbernoulli", p=0.5) +
node("smoking", type="binomial",
formula= ~ -2 + age*param(Sbeta) + sex*0.2) +
node("death", type="binomial",
formula= ~ param(Dintercept) + age*1 + sex*2)
)
# get a real DAG object from this with set values
dag3 <- set_lazy_dag(ldag, params=c(Sbeta=2.1, Dintercept=-10))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.