counterfactual_conjunction {cfid}R Documentation

Counterfactual Conjunction

Description

conj defines a conjunction of counterfactual statements (variables).

cf defines a counterfactual variable y_x.

Usage

counterfactual_conjunction(...)

## S3 method for class 'counterfactual_conjunction'
format(x, var_sep = " /\\ ", ...)

## S3 method for class 'counterfactual_conjunction'
print(x, ...)

## S3 method for class 'counterfactual_conjunction'
e1 + e2

## S3 method for class 'counterfactual_conjunction'
x[i]

## S3 method for class 'counterfactual_variable'
e1 + e2

conj(...)

counterfactual_variable(var, obs = integer(0L), sub = integer(0L))

## S3 method for class 'counterfactual_variable'
format(x, use_primes = TRUE, ...)

## S3 method for class 'counterfactual_variable'
print(x, ...)

cf(var, obs = integer(0L), sub = integer(0L))

Arguments

...

Additional arguments passed to format.counterfactual_variable().

x

A counterfactual_variable or a counterfactual_conjunction object.

var_sep

A character string to separate counterfactual variables.

e1

A counterfactual_variable or a counterfactual_conjunction object.

e2

A counterfactual_variable or a counterfactual_conjunction object.

i

An integer index vector.

var

A character vector of length one naming the variable (i.e., Y).

obs

An integer vector of length one or zero. If given, denotes the observed value of var (i.e., Y = y)

sub

A named integer vector where the names correspond to the variables intervened on (via do(X = x)) and values to the value assignments (their levels, e.g., x).

use_primes

A logical value. If TRUE (the default), any value assignment of a counterfactual variable with obs will be formatted with as many primes in the superscript as the value of obs, e.g., obs = 0 outputs "y", obs = 1 outputs "y'", obs = 2 outputs "y''" and so forth. The alternative when FALSE is to simply denote the obs value via superscript directly as "y^{(obs)}", where obs is evaluated.

Value

conj returns an object of class counterfactual_conjunction.

cf returns an object of class counterfactual_variable.

Counterfactual Conjunctions

A counterfactual conjunction is a conjunction (or a set in some contexts) of counterfactual statements that are assumed to hold simultaneously.

For example, the statement "The value of Y was observed to be y, and the value of Y was observed to be y' under the intervention do(X = x)" consists of two variables: variable Y without intervention, and Y under the intervention do(X = x) (which is Y_x). This conjunction can be succinctly written as y \wedge y'_x.

Conjunctions can also be constructed via the alias conj or iteratively from counterfactual_variable objects (see examples).

Counterfactual Variables

Assume that Y is a single variable and X is a vector of variables. Here, The notation y_x means that the variable Y (var) attains the value y (obs) under the intervention do(X = x) (sub).

Note that different values of obs for a two variables with the same var and the same sub do not denote their actual values, but the levels (i.e., obs = 0 is different from obs = 1, but the variables do not actually attain values 0 and 1). In other words, if var is different for two counterfactual variables, but they have the same value obs, this does not mean that these variables have the same value. They will only actually have the same value if they share both var and obs.

For more information about the do-operator, see Pearl (2009). The shortcut alias cf can also be used to construct counterfactual variables.

Examples

# The conjunction described under 'details'
v1 <- cf("Y", 0)
v2 <- cf("Y", 1, c("X" = 0))
c1 <- conj(v1, v2)

# Alternative construction
c1 <- v1 + v2

# Adding further variables
v3 <- cf("X", 1)
c2 <- c1 + v3

# A specific value of a variable (a unique combination of `var` and `sub`)
# can only appear once in a given conjunction,
# otherwise the conjunction would be trivially inconsistent
v4 <- cf("Y", 0, c("X" = 0))
v5 <- cf("Y", 1, c("X" = 0))
c3 <- try(conj(v4, v5))

# Y without an assigned value or any interventions
cf("Y")

# Y with a value assignment y, but no interventions
cf("Y", 0)

# Y with a different value y', but no interventions
cf("Y", 1)

# Y with the same value as the previous under the intervention do(X = x)
cf("Y", 1, c("X" = 0))

# Y with yet another value y'', under the intervention
# do(X = x', Z = z), i.e., the intervention on X has a different value
# than the previous (x != x') and Z is also assigned the value z
cf("Y", 2, c("X" = 1, "Z" = 0))

[Package cfid version 0.1.7 Index]