tetradrunner: Tetrad Algorithm Runner

View source: R/tetradrunner.R

tetradrunnerR Documentation

Tetrad Algorithm Runner

Description

tetradrunner is the wrapper of Tetrad algorithms.

Usage

ccd(algoId, dataType, df = NULL, dfs = NULL, testId = NULL, scoreId = NULL, 
	priorKnowledge = NULL, numCategoriesToDiscretize = 4,java.parameters = NULL,...)

Arguments

algoId

Tetrad Algorithm Id. To check what algorithms supported, use tetradrunner.listAlgorithms.

dataType

Dataset type either 'continuous','discrete', or 'mixed'.

df

Data frame of dataset.If running multi-dataset algorithms, set it NULL. By default, df=NULL.

dfs

A list of data frames of datasets.If running singular dataset algorithms, set it NULL. By default, dfs=NULL.

testId

Test id indicating the independent test being used by the causal algorithm. To check if the designated algorithm needs an independent test or not, use tetradrunner.getAlgorithmDescription. To check what tests supported, use tetradrunner.listIndTests.

scoreId

Score id indicating the evaluation score being used by the causal algorithm. To check if the designated algorithm needs a score or not, use tetradrunner.getAlgorithmDescription. To check what tests supported, use tetradrunner.listScores.

priorKnowledge

object indicating a prior knowledge of the graph. By default, priorKnowledge=NULL.

numCategoriesToDiscretize

A number of categories of the continuous variable to be discretized. By default, numCategoriesToDiscretize=4.

java.parameters

string indicating an optional parameters for JVM. For example, java.parameters = "-Xmx1024M". By default, java.parameters=NULL.

...

parameters specific to the designed algorithm. To check which parameters the algorithm accepts, use tetradrunner.getAlgorithmParameters.

Details

The Tetrad Runner is a R wrapper implemented for running the search algorithms from the Tetrad library.

More detail about Tetrad implementation, please visit the Tetrad project.

Value

A list containing the result's graph, the result's nodes, and the result's edges.

Examples

data("charity")
tetradrunner.getAlgorithmDescription(algoId = 'fges')
tetradrunner.getAlgorithmParameters(algoId = 'fges',scoreId = 'sem-bic')

tetradrunner <- tetradrunner(algoId = 'fges',df = charity,scoreId = 'sem-bic',dataType = 'continuous')
tetradrunner$edges

tetradrunner <- tetradrunner(algoId = 'fges',df = charity,scoreId = 'sem-bic',dataType = 'continuous',
faithfulnessAssumed=TRUE,maxDegree=-1,verbose=TRUE)
tetradrunner$edges

# Using the default score
tetradrunner <- tetradrunner(algoId = 'fges',df = charity,dataType = 'continuous')
tetradrunner$edges

# Bootstrapping
tetradrunner <- tetradrunner(algoId = 'fges',df = charity,dataType = 'continuous',
faithfulnessAssumed=TRUE,maxDegree=-1,verbose=TRUE,
numberResampling = 10,resamplingEnsemble = 0,addOriginalDataset = TRUE)
tetradrunner$edges #Show the result's edges
tetradrunner$nodes #Show the result's nodes

# Get BIC scores
graph <- tetradrunner$graph
graph$getAttribute('BIC')

nodes <- graph$getNodes()
for(i in 0:as.integer(nodes$size()-1)){
    node <- nodes$get(i)
    cat(node$getName(),": ",node$getAttribute('BIC'),"\n")
}


bd2kccd/r-causal documentation built on Sept. 7, 2024, 8:32 p.m.