parents: Show Node Parents Given DAG Object

View source: R/simcausal.r

parentsR Documentation

Show Node Parents Given DAG Object

Description

Given a vector of node names, this function provides the name(s) of node parents that were obtained by parsing the node formulas.

Usage

parents(DAG, nodesChr)

Arguments

DAG

A DAG object that was specified by calling set.DAG

nodesChr

A vector of node names that are already defined in DAG

Value

A list with parent names for each node name in nodesChr

Examples


D <- DAG.empty()
D <- D + node(name="W1", distr="rbern", prob=plogis(-0.5))
D <- D + node(name="W2", distr="rbern", prob=plogis(-0.5 + 0.5*W1))
D <- D + node(name="A", distr="rbern", prob=plogis(-0.5 - 0.3*W1 - 0.3*W2))
D <- D + node(name="Y", distr="rbern", prob=plogis(-0.1 + 1.2*A + 0.3*W1 + 0.3*W2), EFU=TRUE)
D <- set.DAG(D)
parents(D, c("W2", "A", "Y"))

simcausal documentation built on Oct. 29, 2022, 1:13 a.m.