Crandore Hub

tpc

Tiered PC Algorithm

Constraint-based causal discovery using the PC algorithm while accounting for a partial node ordering, for example a partial temporal ordering when the data were collected in different waves of a cohort study. Andrews RM, Foraita R, Didelez V, Witte J (2021) <arXiv:2108.13395> provide a guide how to use tpc to analyse cohort data.

README

# tPC - Causal discovery with temporal background knowledge

This package implements the tPC algorithm for causal discovery. The 't' stands for 'temporal' or 'tiers' and
indicates that background knowledge in the form of a partial node/variable ordering is available.
Our implementation is a modified version of `pc` from the `pcalg` package (Kalisch et al. 2012) with the following
additional options:

Using the `tiers` argument, the user can allocate each node/variable to a tier. Specifying tiers has two effects:
First, conditional independence testing is restricted such that the variables in the conditioning set do not
lie in the future of the variables whose independence is being tested. This reduces the number of
unnecessary conditional independence tests and thus makes the algorithm more reliable. Second, edges between
nodes in different tiers are oriented from the earlier tier to the later tier. This usually results in a more
informative output. Both modifications were suggested in Spirtes et al. (2000), p. 93.

Additionally, further directed edges may be blacklisted using the `forbEdges` argument. In contrast to `pcalg`,
this allows the user to forbid one direction of an edge, but allow the other one. The arguments `context.all` and
`context.tier` function as whitelists. Variables in `context.all` are glocal context variables; as such, they are
parents of all other non-context nodes in the graphs (examples are variables encoding batch effect in gene expression data, or 'sex'
and 'country' in a cohort study). Variables in `context.tier` are tier-specific context variables,
which are parents of all non-context nodes in the same tier (e.g. 'calender year' if the tiers encode different years).

The package also includes a function called `ida_invalid`, which determines possibly valid adjustment sets from a graph
that is not a valid CPDAG or MPDAG.

## Installation
Install `graph` and `RBGL` from Bioconductor and `devtools` from CRAN, and make sure that Rtools40 is installed on your computer.
Then run the following commands:

```R
devtools::install_github("bips-hb/tpc")
library(tpc)
```

## References
  Markus Kalisch, Martin Maechler, Diego Colombo, Marloes H. Maathuis, Peter Buehlmann (2012). Causal
  Inference Using Graphical Models with the R Package pcalg. Journal of Statistical Software, 47(11), 1-26.
  URL https://www.jstatsoft.org/article/view/v047i11.
  
  Peter Spirtes, Clark Glymour, Richard Scheines (2000). Causation, Prediction, and Search. Second Edition. MIT Press, Cambridge, Massachusetts, USA.

Versions across snapshots

VersionRepositoryFileSize
1.0 rolling linux/jammy R-4.5 tpc_1.0.tar.gz 619.3 KiB
1.0 rolling linux/noble R-4.5 tpc_1.0.tar.gz 619.3 KiB
1.0 rolling source/ R- tpc_1.0.tar.gz 619.3 KiB
1.0 latest linux/jammy R-4.5 tpc_1.0.tar.gz 619.3 KiB
1.0 latest linux/noble R-4.5 tpc_1.0.tar.gz 619.3 KiB
1.0 latest source/ R- tpc_1.0.tar.gz 619.3 KiB
1.0 2026-04-26 source/ R- tpc_1.0.tar.gz 619.3 KiB
1.0 2026-04-23 source/ R- tpc_1.0.tar.gz 619.3 KiB
1.0 2025-04-20 source/ R- tpc_1.0.tar.gz 619.3 KiB

Dependencies (latest)

Depends

Imports

Suggests