bd2kccd / r-causal

R Wrapper for Tetrad Library
35 stars 19 forks source link

Error: object 'fges' not found #95

Closed hangjianli closed 5 years ago

hangjianli commented 5 years ago

I followed the instructions here bd2kccd/r-causal and successfully installed rcausal package. But the package doesn't seem to contain the function fges. Has this function been removed from the package?

R version: _
platform x86_64-apple-darwin15.6.0
arch x86_64
os darwin15.6.0
system x86_64, darwin15.6.0
status
major 3
minor 6.1
year 2019
month 07
day 05
svn rev 76782
language R
version.string R version 3.6.1 (2019-07-05) nickname Action of the Toes

chirayukong commented 5 years ago

The way to call the causal algorithm has been changed. We created a generic class called tetradrunner that generalizes the argument passage. It can directly pass arguments to the specific algorithm. The example is following:

library(rcausal)
data("charity")   #Load the charity dataset

tetradrunner.getAlgorithmDescription(algoId = 'fges')
#Compute FGES search
tetradrunner <- tetradrunner(algoId = 'fges',df = charity,scoreId = 'sem-bic',
dataType = 'continuous',faithfulnessAssumed=TRUE,maxDegree=-1,verbose=TRUE)

tetradrunner$nodes #Show the result's nodes
tetradrunner$edges #Show the result's edges

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")
}
hangjianli commented 5 years ago

Got it. Thanks!