R/translation-modules.R
create_response_function.Rd
Translate regular DAG to response functions
create_response_function(graph, right.vars, cond.vars)
An aaa-igraph-package object that represents a directed acyclic graph that contains certain edge attributes. The shiny app returns a graph in this format and see examples.
Vertices of graph on the right side
Vertices of graph on the left side
A list of functions representing the response functions
### confounded exposure and outcome
b <- igraph::graph_from_literal(X -+ Y, Ur -+ X, Ur -+ Y)
V(b)$leftside <- c(0,0,0)
V(b)$latent <- c(0,0,1)
V(b)$nvals <- c(2,2,2)
E(b)$rlconnect <- E(b)$edge.monotone <- c(0, 0, 0)
cond.vars <- V(b)[V(b)$leftside == 1 & names(V(b)) != "Ul"]
right.vars <- V(b)[V(b)$leftside == 0 & names(V(b)) != "Ur"]
create_response_function(b, right.vars, cond.vars)
#> $X
#> $X$index
#> [1] 0 1
#>
#> $X$values
#> $X$values[[1]]
#> function ()
#> 0
#> <environment: base>
#>
#> $X$values[[2]]
#> function ()
#> 1
#> <environment: base>
#>
#>
#>
#> $Y
#> $Y$index
#> [1] 0 1 2 3
#>
#> $Y$values
#> $Y$values[[1]]
#> function (X = NULL)
#> switch(paste0(X), `0` = 0, `1` = 0)
#> <environment: base>
#>
#> $Y$values[[2]]
#> function (X = NULL)
#> switch(paste0(X), `0` = 1, `1` = 0)
#> <environment: base>
#>
#> $Y$values[[3]]
#> function (X = NULL)
#> switch(paste0(X), `0` = 0, `1` = 1)
#> <environment: base>
#>
#> $Y$values[[4]]
#> function (X = NULL)
#> switch(paste0(X), `0` = 1, `1` = 1)
#> <environment: base>
#>
#>
#>