Learn R Programming

R6causal (version 0.8.3)

ParallelWorld: R6 Class for parallel world models

Description

R6 Class for parallel world models

R6 Class for parallel world models

Arguments

Super class

R6causal::SCM -> ParallelWorld

Active bindings

num_worlds

Number of parallel worlds.

worldnames

Names of parallel worlds.

worldsuffix

Suffix used for parallel world variables.

originalscm

SCM from which the parallel worlds are derived.

dolist

List containing the interventions for each world.

Methods

Inherited methods


Method new()

Create a new ParallelWorld object from an SCM object.

Usage

ParallelWorld$new(scm, dolist, worldnames = NULL, worldsuffix = "_")

Arguments

scm

An SCM object.

dolist

A list containing the interventions for each world. Each element of the list has the fields:

  • target: a vector of variable names that specify the target variable(s) of the counterfactual intervention.

  • ifunction: a list of functions for the counterfactual intervention.

worldnames

A character vector giving the names of the parallel worlds.

worldsuffix

A text giving the suffix used for parallel world variables before the world number. Defaults to "_" and the worlds have then suffixes "_1", "_2", "_3", ...

Returns

A new `ParallelWorld` object that also belongs to class `SCM`.

Examples

backdoor_parallel <- ParallelWorld$new(
                        backdoor,
                        dolist=list(
                            list(target = "x", 
                                 ifunction = 0),
                            list(target = list("z","x"), 
                                 ifunction = list(1,0))
                        )
)
backdoor_parallel 
plot(backdoor_parallel)


Method clone()

The objects of this class are cloneable with this method.

Usage

ParallelWorld$clone(deep = FALSE)

Arguments

deep

Whether to make a deep clone.

Details

Inherits R6 class SCM.

Examples

Run this code

## ------------------------------------------------
## Method `ParallelWorld$new`
## ------------------------------------------------

backdoor_parallel <- ParallelWorld$new(
                        backdoor,
                        dolist=list(
                            list(target = "x", 
                                 ifunction = 0),
                            list(target = list("z","x"), 
                                 ifunction = list(1,0))
                        )
)
backdoor_parallel 
plot(backdoor_parallel)

Run the code above in your browser using DataLab