Skip to contents

Interprets the position of one or more digits (specified by position) in a nodal type. Alternatively returns nodal type digit positions that correspond to one or more given condition.

Usage

interpret_type(model, condition = NULL, position = NULL, nodes = NULL)

Arguments

model

A causal_model. A model object generated by make_model.

condition

A vector of characters. Strings specifying the child node, followed by '|' (given) and the values of its parent nodes in model.

position

A named list of integers. The name is the name of the child node in model, and its value a vector of digit positions in that node's nodal type to be interpreted. See `Details`.

nodes

A vector of names of nodes. Can be used to limit interpretation to selected nodes.

Value

A named list with interpretation of positions of the digits in a nodal type

Details

A node for a child node X with k parents has a nodal type represented by X followed by 2^k digits. Argument position allows user to interpret the meaning of one or more digit positions in any nodal type. For example position = list(X = 1:3) will return the interpretation of the first three digits in causal types for X. Argument condition allows users to query the digit position in the nodal type by providing instead the values of the parent nodes of a given child. For example, condition = 'X | Z=0 & R=1' returns the digit position that corresponds to values X takes when Z = 0 and R = 1.

Examples

model <- make_model('R -> X; Z -> X; X -> Y')
#Return interpretation of all digit positions of all nodes
interpret_type(model)
#> $R
#>   node position display interpretation
#> 1    R       NA      R0          R = 0
#> 2    R       NA      R1          R = 1
#> 
#> $Z
#>   node position display interpretation
#> 1    Z       NA      Z0          Z = 0
#> 2    Z       NA      Z1          Z = 1
#> 
#> $X
#>   node position display    interpretation
#> 1    X        1 X[*]*** X | R = 0 & Z = 0
#> 2    X        2 X*[*]** X | R = 1 & Z = 0
#> 3    X        3 X**[*]* X | R = 0 & Z = 1
#> 4    X        4 X***[*] X | R = 1 & Z = 1
#> 
#> $Y
#>   node position display interpretation
#> 1    Y        1   Y[*]*      Y | X = 0
#> 2    Y        2   Y*[*]      Y | X = 1
#> 
#Example using digit position
interpret_type(model, position = list(X = c(3,4), Y = 1))
#> $<NA>
#> NULL
#> 
#> $<NA>
#> NULL
#> 
#> $X
#>   node position display    interpretation
#> 1    X        3 X**[*]* X | R = 0 & Z = 1
#> 2    X        4 X***[*] X | R = 1 & Z = 1
#> 
#> $Y
#>   node position display interpretation
#> 1    Y        1   Y[*]*      Y | X = 0
#> 
interpret_type(model, position = list(R = 1))
#> $R
#>   node position display interpretation
#> 1    R        1  RNA[*]        R |  = 
#> 
#> $<NA>
#> NULL
#> 
#> $<NA>
#> NULL
#> 
#> $<NA>
#> NULL
#> 
#Example using condition
interpret_type(model, condition = c('X | Z=0 & R=1', 'X | Z=0 & R=0'))
#> $<NA>
#> NULL
#> 
#> $<NA>
#> NULL
#> 
#> $X
#>   node position display    interpretation
#> 1    X        1 X[*]*** X | R = 0 & Z = 0
#> 2    X        2 X*[*]** X | R = 1 & Z = 0
#> 
#> $<NA>
#> NULL
#> 
# Example using node names
interpret_type(model, nodes = c("Y", "R"))
#> $Y
#>   node position display interpretation
#> 1    Y        1   Y[*]*      Y | X = 0
#> 2    Y        2   Y*[*]      Y | X = 1
#> 
#> $R
#>   node position display interpretation
#> 1    R       NA      R0          R = 0
#> 2    R       NA      R1          R = 1
#>