dag_greta {causact} | R Documentation |
The input graph object should be of class causact_graph
and created using dag_create()
. The specification of a completely consistent joint distribution is left to the user. Helpful error messages are scheduled for future versions of the causact
package.
dag_greta(graph, mcmc = TRUE, meaningfulLabels = TRUE, ...)
graph |
a graph object of class |
mcmc |
a logical value indicating whether to sample from the posterior distribution. When |
meaningfulLabels |
a logical value indicating whether to replace the indexed variable names in |
... |
additional arguments to be passed onto |
If mcmc=TRUE
, returns a dataframe of posterior distribution samples corresponding to the input 'causact_graph'. Each column is a parameter and each row a draw from the posterior sample output. If mcmc=FALSE
, running dag_greta
returns a character string of code that would help the user create three objects representing the posterior distribution:
draws
: An mcmc.list object containing raw output from the HMCMC sampler used by greta
.
drawsDF
: A wide data frame with all latent variables as columns and all draws as rows. This data frame is useful for calculations based on the posterior
tidyDrawsDF
: A long data frame with each draw represented on one line. This data frame is useful for plotting posterior distributions.
library(greta) 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() gretaCode = graph %>% dag_greta(mcmc=FALSE) ## Not run: ## default functionality returns a data frame # below requires Tensorflow installation drawsDF = graph %>% dag_greta() drawsDF %>% dagp_plot() ## End(Not run)