mat2targets function

Conversion between an intervention matrix and a list of intervention targets

Conversion between an intervention matrix and a list of intervention targets

In a data set with nn measurements of pp variables, intervened variables can be specified in two ways:

  • with a logical intervention matrix of dimension n×pn × p, where the entry [i, j] indicates whether variable jj has been intervened in measurement ii; or
  • with a list of (unique) intervention targets and a pp-dimensional vector indicating the indices of the intervention targets of the pp measurements.

The function mat2targets converts the first representation to the second one, the function targets2mat does the reverse conversion. The second representation can be used to create scoring objects (see Score) and to run causal inference methods based on interventional data such as gies or simy. UTF-8

mat2targets(A) targets2mat(p, targets, target.index)

Arguments

  • A: Logical matrix with nn rows and pp columns, where nn

    is the sample size of a data set with jointly interventional and observational data, and pp is the number of variables. A[i, j]

    is TRUE iff variable j is intervened in data point i.

  • p: Number of variables

  • targets: List of unique intervention targets

  • target.index: Vector of intervention target indices. The intervention target of data point i is encoded as targets[[target.index[i]]].

Returns

mat2targets returns a list with two components: - targets: A list of unique intervention targets.

  • target.index: A vector of intervention target indices. The intervention target of data point i is encoded as targets[[target.index[i]]].

Author(s)

Alain Hauser (alain.hauser@bfh.ch )

See Also

Score, gies, simy

Examples

## Specify interventions using a matrix p <- 5 n <- 10 A <- matrix(FALSE, nrow = n, ncol = p) for (i in 1:n) A[i, (i-1) %% p + 1] <- TRUE ## Generate list of intervention targets and corresponding indices target.list <- mat2targets(A) for (i in 1:length(target.list$target.index)) sprintf("Intervention target of %d-th data point: %d", i, target.list$targets[[target.list$target.index[i]]]) ## Convert back to matrix representation all(A == targets2mat(p, target.list$targets, target.list$target.index))