dagp_plot {causact} | R Documentation |
Plot posterior distribution from dataframe of posterior draws.
Description
Plot the posterior distribution of all latent parameters using a dataframe of posterior draws from a causact_graph
model.
Usage
dagp_plot(drawsDF, densityPlot = FALSE, abbrevLabels = FALSE)
Arguments
drawsDF |
the dataframe output of |
densityPlot |
If |
abbrevLabels |
If |
Value
a credible interval plot of all latent posterior distribution parameters.
Examples
# A simple example
posteriorDF = data.frame(x = rnorm(100),
y = rexp(100),
z = runif(100))
posteriorDF %>%
dagp_plot(densityPlot = TRUE)
# More complicated example requiring 'numpyro'
## Not run:
# Create a 2 node graph
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")
graph %>% dag_render()
# below requires Tensorflow installation
drawsDF = graph %>% dag_numpyro(mcmc=TRUE)
drawsDF %>% dagp_plot()
## End(Not run)
# A 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()
## Not run:
# below requires Tensorflow installation
drawsDF = graph %>% dag_numpyro(mcmc=TRUE)
drawsDF %>% dagp_plot()
## End(Not run)
[Package causact version 0.5.5 Index]