Skip to content

Handling deterministic child node #55

@flyaflya

Description

@flyaflya

See the issue described here: https://github.com/prabinov42/Greta_causact_question/blob/main/greta_causact_2.md

If a child node is deterministic and not used as a parent node, causact incorrectly labels it as a distribution.

Temporary fix (use mcmc=FALSE):

graph %>% dag_greta(mcmc=FALSE)

Then delete distribution(lbs) <- kgs * 2.2 #LIKELIHOOD in the output code so you are left with the below:

## The below greta code will return a posterior distribution 
## for the given DAG. Either copy and paste this code to use greta
## directly, evaluate the output object using 'eval', or 
## or (preferably) use dag_greta(mcmc=TRUE) to return a data frame of
## the posterior distribution: 
lbs <- as_data(df$weight_lbs)   #DATA
mu     <- normal(mean = 90, sd = 10)      #PRIOR
sigma  <- exponential(rate = 1/20)        #PRIOR
kgs    <- normal(mean = mu, sd = sigma)   #PRIOR
lbs    <- kgs * 2.2   #OPERATION
#### DELETED LINE LOCATION ##########
gretaModel  <- model(kgs,mu,sigma)   #MODEL
meaningfulLabels(graph)
draws       <- mcmc(gretaModel)              #POSTERIOR
drawsDF     <- replaceLabels(draws) %>% as.matrix() %>%
                dplyr::as_tibble()           #POSTERIOR
tidyDrawsDF <- drawsDF %>% addPriorGroups()  #POSTERIOR

Run the above code to get drawsDF. If you now do drawsDF %>% dagp_plot(), you will see kgs as a column.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions