fci: Perform causal discovery using the FCI algorithm

View source: R/fci.R

fciR Documentation

Perform causal discovery using the FCI algorithm

Description

This is a wrapper function for the fci function as implemented in the pcalg package. All computations are carried out by the pcalg package. The default output object however matches that of tfci, see this function for details about how the adjacency matrix is encoded.

Usage

fci(
  data = NULL,
  sparsity = 10^(-1),
  test = regTest,
  suffStat = NULL,
  method = "stable.fast",
  methodNA = "none",
  methodOri = "conservative",
  output = "pag",
  varnames = NULL,
  ...
)

Arguments

data

A data.frame with data. All variables should be assigned to exactly one period by prefixing them with the period name (see example below).

sparsity

The sparsity level to be used for independence testing (i.e. significance level threshold to use for each test).

test

A procedure for testing conditional independence. The default, regTest uses a regression-based information loss test. Another available option is corTest which tests for vanishing partial correlations. User supplied functions may also be used, see details below about the required syntax.

suffStat

Sufficient statistic. If this argument is supplied, the sufficient statistic is not computed from the inputted data. The format and contents of the sufficient statistic depends on which test is being used.

method

Which method to use for skeleton construction, must be "stable", "original", or "stable.fast" (the default). See skeleton for details.

methodNA

Method for handling missing information (NA values). Must be one of "none" (default, an error is thrown if NAs are present), "cc" (complete case analysis, deletes all observations that have any NA values), or "twd" (test wise deletion, omits observations with missing information test-by-test) (further details below).

methodOri

Method for handling conflicting separating sets when orienting edges, must be one of "standard", "conservative" (the default) or "maj.rule". See pc for further details.

output

One of "pag" or "fciAlgo". If "pag" a partial ancestral graph (PAG) object is outputted. If "fciAlgo" the PAG is outputted as the object class fciAlgo-class from the pcalg package. This is intended for compatability with tools from that package.

varnames

A character vector of variable names. It only needs to be supplied if the data argument is not used, and data are hence passed exclusively through the suffStat argument.

...

Further optional arguments which are passed to skeleton for the skeleton constructing phase.

Examples

# simulate linear Gaussian data w unobserved variable L1
n <- 100
L1 <- rnorm(n) 
X1 <- rnorm(n)
X2 <- L1 + X1 + rnorm(n)
X3 <- X1 + rnorm(n)
X4 <- X3 + L1 + rnorm(n)
d <- data.frame(p1_X1 = X1,
                p1_X2 = X2,
                p2_X3 = X3,
                p2_X4 = X4)

# use FCI algorithm to recover PAG                
fci(d, test = corTest)



causalDisco documentation built on Jan. 20, 2026, 5:09 p.m.

Related to fci in causalDisco...