Class ExternalAlgorithmBNTPc

java.lang.Object
edu.cmu.tetrad.algcomparison.algorithm.ExternalAlgorithm
edu.cmu.tetrad.algcomparison.algorithm.external.ExternalAlgorithmBNTPc
All Implemented Interfaces:
Algorithm, HasParameters, TetradSerializable, Serializable

public class ExternalAlgorithmBNTPc extends ExternalAlgorithm
An API to allow results from external algorithms to be included in a report through the algrorithm comparison tool. This one is for matrix generated by PC in pcalg. See below. This script can generate the files in R.

library("MASS"); library("pcalg");

path<-"/Users/user/tetrad/comparison-final"; simulation<-1;

subdir<-"pc.solve.confl.TRUE"; dir.create(paste(path, "/save/", simulation, "/", subdir, sep=""));

for (i in 1:10) { data<-read.table(paste(path, "/save/", simulation, "/data/data.", i, ".txt", sep=""), header=TRUE) n<-nrow(data) C<-cor(data) v<-names(data) suffStat<-list(C = C, n=n) pc.fit<-pc(suffStat=suffStat, indepTest=gaussCItest, alpha=0.001, labels=v, solve.conf=TRUE) A<-as(pc.fit, "amat") name<-paste(path, "/save/", simulation, "/", subdir, "/graph.", i, ".txt", sep="") print(name) write.matrix(A, file=name, sep="\t") }

Author:
josephramsey
See Also:
  • Constructor Details

    • ExternalAlgorithmBNTPc

      public ExternalAlgorithmBNTPc(String extDir)
    • ExternalAlgorithmBNTPc

      public ExternalAlgorithmBNTPc(String extDir, String shortDecription)
  • Method Details

    • search

      public Graph search(DataModel dataSet, Parameters parameters)
      Reads in the relevant graph from the file (see above) and returns it.
      Parameters:
      dataSet - The data set to run to the search on.
      parameters - The paramters of the search.
      Returns:
      The result graph.
    • getComparisonGraph

      public Graph getComparisonGraph(Graph graph)
      Returns the CPDAG of the supplied DAG.
      Parameters:
      graph - The true directed graph, if there is one.
      Returns:
      The comparison graph.
    • getDescription

      public String getDescription()
      Description copied from interface: Algorithm
      Returns a short, one-line description of this algorithm. This will be printed in the report.
      Returns:
      This description.
    • getDataType

      public DataType getDataType()
      Description copied from interface: Algorithm
      Returns the data type that the search requires, whether continuous, discrete, or mixed.
      Returns:
      This type.
    • getElapsedTime

      public long getElapsedTime(DataModel dataSet, Parameters parameters)
      Specified by:
      getElapsedTime in class ExternalAlgorithm