dag_plate {causact} | R Documentation |
Given a graph object of class causact_graph
, create collections of nodes that should be repeated i.e. represent multiple instances of a random variable, random vector, or random matrix. When nodes are on more than one plate, graph rendering will treat each unique combination of plates as separate plates.
dag_plate( graph, descr, label, nodeLabels, data = as.character(NA), addDataNode = FALSE, rhs = NA )
graph |
a graph object of class |
descr |
a longer more descriptive label for the cluster/plate. |
label |
a short character string to use as an index. |
nodeLabels |
a character vector of node labels or descriptions to include in the list of nodes. |
data |
a vector representing the categorical data whose unique values become the plate index. To use with |
addDataNode |
a logical value. When |
rhs |
Optional |
an expansion of the input causact_graph
object with an added plate representing the repetition of nodeLabels
for each unique value of data
.
# single plate example graph = dag_create() %>% dag_node("Get Card","y", rhs = bernoulli(theta), data = carModelDF$getCard) %>% dag_node(descr = "Card Probability by Car",label = "theta", rhs = beta(2,2), child = "y") %>% dag_node("Car Model","x", data = carModelDF$carModel, child = "y") %>% dag_plate("Car Model","x", data = carModelDF$carModel, nodeLabels = "theta") graph %>% dag_render() # multiple plate example library(dplyr) poolTimeGymDF = gymDF %>% mutate(stretchType = ifelse(yogaStretch == 1, "Yoga Stretch", "Traditional")) %>% group_by(gymID,stretchType,yogaStretch) %>% summarize(nTrialCustomers = sum(nTrialCustomers), nSigned = sum(nSigned)) graph = dag_create() %>% dag_node("Cust Signed","k", rhs = binomial(n,p), data = poolTimeGymDF$nSigned) %>% dag_node("Probability of Signing","p", rhs = beta(2,2), child = "k") %>% dag_node("Trial Size","n", data = poolTimeGymDF$nTrialCustomers, child = "k") %>% dag_plate("Yoga Stretch","x", nodeLabels = c("p"), data = poolTimeGymDF$stretchType, addDataNode = TRUE) %>% dag_plate("Observation","i", nodeLabels = c("x","k","n")) %>% dag_plate("Gym","j", nodeLabels = "p", data = poolTimeGymDF$gymID, addDataNode = TRUE) graph %>% dag_render()