realise_outcomes: Realise outcomes

View source: R/realise_outcomes.R

realise_outcomesR Documentation

Realise outcomes

Description

Realise outcomes for all causal types. Calculated by sequentially calculating endogenous nodes. If a do operator is applied to any node then it takes the given value and all its descendants are generated accordingly.

Usage

realise_outcomes(model, dos = NULL, node = NULL, add_rownames = TRUE)

Arguments

model

A causal_model. A model object generated by make_model.

dos

A named list. Do actions defining node values, e.g., list(X = 0, M = 1).

node

A character. An optional quoted name of the node whose outcome should be revealed. If specified all values of parents need to be specified via dos.

add_rownames

logical indicating whether to add causal types as rownames to the output

Details

If a node is not specified all outcomes are realised for all possible causal types consistent with the model. If a node is specified then outcomes of Y are returned conditional on different values of parents, whether or not these values of the parents obtain given restrictions under the model.

realise_outcomes starts off by creating types (via get_nodal_types). It then takes types of endogenous and reveals their outcome based on the value that their parents took. Exogenous nodes outcomes correspond to their type.

Value

A data.frame object of revealed data for each node (columns) given causal / nodal type (rows) .

Examples


make_model("X -> Y") |>
  realise_outcomes()

make_model("X -> Y <- W") |>
set_restrictions(labels = list(X = "1", Y="0010"), keep = TRUE) |>
 realise_outcomes()

make_model("X1->Y; X2->M; M->Y") |>
realise_outcomes(dos = list(X1 = 1, M = 0))

# With node specified
make_model("X->M->Y") |>
realise_outcomes(node = "Y")

make_model("X->M->Y") |>
realise_outcomes(dos = list(M = 1), node = "Y")


CausalQueries documentation built on Oct. 20, 2023, 1:06 a.m.