grab: Grab

View source: R/grab.R

grabR Documentation

Grab

Description

Returns specified elements from a causal_model. Users can use grab to extract model's components or objects implied by the model structure including nodal types, causal types, parameter priors, parameter posteriors, type priors, type posteriors, and other relevant elements. See argument object for other options.

Usage

grab(model, object = NULL, ...)

Arguments

model

A causal_model. A model object generated by make_model.

object

A character string specifying the component to retrieve. Available options are:

  • "causal_statement" a character. Statement describing causal relations using dagitty syntax,

  • "dag" A data frame with columns ‘parent’ and ‘children’ indicating how nodes relate to each other,

  • "nodes" A list containing the nodes in the model,

  • "parents_df" a table listing nodes, whether they are root nodes or not, and the number and names of parents they have,

  • "parameters_df" a data frame containing parameter information,

  • "causal_types" a data frame listing causal types and the nodal types that produce them,

  • "causal_types_interpretation" a key to interpreting types; see "?interpret_type" for options,

  • "nodal_types" a list with the nodal types of the model,

  • "data_types" a list with the all data types consistent with the model; for options see "?get_all_data_types",

  • "event_probabilities" a vector of data (event) probabilities given a parameter vector; for options see "?get_event_probabilities",

  • "ambiguities_matrix" a matrix mapping from causal types into data types,

  • "parameters" a vector of 'true' parameters,

  • "parameter_names" a vector of names of parameters,

  • "parameter_mapping" a matrix mapping from parameters into data types,

  • "parameter_matrix" a matrix mapping from parameters into causal types,

  • "prior_hyperparameters" a vector of alpha values used to parameterize Dirichlet prior distributions; optionally provide node names to reduce output "grab(prior_hyperparameters, c('M', 'Y'))"

  • "prior_distribution" a data frame of the parameter prior distribution,

  • "posterior_distribution" a data frame of the parameter posterior distribution,

  • "posterior_event_probabilities" a sample of data (event) probabilities from the posterior,

  • "stan_objects" stan_objects is a list of Stan outputs that can include the stanfit object, the data that was used, and distributions over causal types and event probabilities.

  • "data" the data that was provided to update the model,

  • "stan_fit" the stanfit object generated by Stan,

  • "stan_summary" a summary of the stanfit object generated by Stan,

  • "type_prior" a matrix of type probabilities using priors,

  • "type_distribution" a matrix of type probabilities using posteriors,

...

Other arguments passed to helper "get_*" functions.

Value

Objects from a causal_model as specified.

Examples


model <-
  make_model('X -> Y') |>
   update_model(
   keep_event_probabilities = TRUE,
   keep_fit = TRUE,
   refresh = 0 )

grab(model, object = "causal_statement")
grab(model, object = "dag")
grab(model, object = "nodes")
grab(model, object = "parents_df")
grab(model, object = "parameters_df")
grab(model, object = "causal_types")
grab(model, object = "causal_types_interpretation")
grab(model, object = "nodal_types")
grab(model, object = "data_types")
grab(model, object = "event_probabilities")
grab(model, object = "ambiguities_matrix")
grab(model, object = "parameters")
grab(model, object = "parameter_names")
grab(model, object = "parameter_mapping")
grab(model, object = "parameter_matrix")
grab(model, object = "prior_hyperparameters")
grab(model, object = "prior_distribution")
grab(model, object = "posterior_distribution")
grab(model, object = "posterior_event_probabilities")
grab(model, object = "stan_objects")
grab(model, object = "data")
grab(model, object = "stan_fit")
grab(model, object = "stan_summary")
grab(model, object = "type_prior")
grab(model, object = "type_distribution")

# Example of arguments passed on to helpers
grab(model,
  object = "event_probabilities",
  parameters = c(.6, .4, .1, .1, .7, .1))




macartan/gbiqq documentation built on April 28, 2024, 10:07 p.m.