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
|
x |
A |
var_sep |
A |
e1 |
A |
e2 |
A |
i |
An |
var |
A character vector of length one naming the variable
(i.e., |
obs |
An integer vector of length one or zero. If given, denotes
the observed value of |
sub |
A named integer vector where the names correspond to the
variables intervened on (via |
use_primes |
A |
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))