dag_greta {causact} | R Documentation |
Generate a representative sample of the posterior distribution
Description
This function is currently defunct. It has been superseded by dag_numpyro()
because of tricky and sometimes unresolvable installation issues related to the greta package's use of tensorflow. If the greta package resolves those issues, this function may return, but please use dag_numpyro()
as a direct replacement.
Generate a representative sample of the posterior distribution. 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.
Usage
dag_greta(graph, mcmc = TRUE, meaningfulLabels = TRUE, ...)
Arguments
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 |
Value
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 bygreta
. -
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.
Examples
## Not run:
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)
## default functionality returns a data frame
# below requires Tensorflow installation
drawsDF = graph %>% dag_greta()
drawsDF %>% dagp_plot()
## End(Not run)