Class MixedUtils

java.lang.Object
edu.pitt.csb.mgm.MixedUtils

public class MixedUtils extends Object
Created by ajsedgewick on 7/29/15.
  • Field Details

  • Constructor Details

    • MixedUtils

      public MixedUtils()
  • Method Details

    • getDiscreteInds

      public static int[] getDiscreteInds(List<Node> nodes)
    • getContinuousInds

      public static int[] getContinuousInds(List<Node> nodes)
    • makeContinuousData

      public static DataSet makeContinuousData(DataSet dsMix)
    • makeMixedData

      public static DataSet makeMixedData(DataSet dsCont, Map<String,String> nodeDists, int numCategories)
    • makeMixedData

      public static DataSet makeMixedData(DataSet dsCont, Map<String,Integer> nodeDists)
    • deepCopy

      public static DataSet deepCopy(DataSet ds)
      Makes a deep copy of a dataset (Nodes copied as well). Useful for paralellization
      Parameters:
      ds - dataset to be copied
    • getContinousData

      public static DataSet getContinousData(DataSet ds)
    • getDiscreteData

      public static DataSet getDiscreteData(DataSet ds)
    • getDiscLevels

      public static int[] getDiscLevels(DataSet ds)
    • colMax

      public static int[] colMax(cern.colt.matrix.DoubleMatrix2D m)
      return vector of the maximum of each column in m (as ints, i.e. for discrete data)
      Parameters:
      m -
      Returns:
    • vecMax

      public static double vecMax(cern.colt.matrix.DoubleMatrix1D vec)
    • numVals

      public static double numVals(cern.colt.matrix.DoubleMatrix1D vec)
    • valSet

      public static Set<Double> valSet(cern.colt.matrix.DoubleMatrix1D vec)
    • GaussianTrinaryPm

      public static GeneralizedSemPm GaussianTrinaryPm(Graph trueGraph, HashMap<String,String> nodeDists, int maxSample, String paramTemplate) throws IllegalStateException
      Throws:
      IllegalStateException
    • GaussianCategoricalPm

      public static GeneralizedSemPm GaussianCategoricalPm(Graph trueGraph, String paramTemplate) throws IllegalStateException
      Throws:
      IllegalStateException
    • setStartsWith

      public static void setStartsWith(String sta, String template, GeneralizedSemPm pm)
      Set all existing parameters that begins with sta to template and also set template for any new parameters
    • GaussianCategoricalIm

      public static GeneralizedSemIm GaussianCategoricalIm(GeneralizedSemPm pm)
    • GaussianCategoricalIm

      public static GeneralizedSemIm GaussianCategoricalIm(GeneralizedSemPm pm, boolean discParamRand)
      This method is needed to normalize edge parameters for an Instantiated Mixed Model Generates edge parameters for c-d and d-d edges from a single weight, abs(w), drawn by the normal IM constructor. Abs(w) is used for d-d edges.

      For deterministic, c-d are evenly spaced between -w and w, and d-d are a matrix with w on the diagonal and -w/(categories-1) in the rest. For random, c-d params are uniformly drawn from 0 to 1 then transformed to have w as max value and sum to 0.

      Parameters:
      pm -
      discParamRand - true for random edge generation behavior, false for deterministic
      Returns:
    • getEdgeParams

      public static List<String> getEdgeParams(String s1, String s2, GeneralizedSemPm pm)
    • arrayPermute

      public static double[] arrayPermute(double[] a)
    • arrayPermute

      public static int[] arrayPermute(int[] a)
    • evenSplitVector

      public static double[] evenSplitVector(double w, int L)
    • getEdgeParams

      public static List<String> getEdgeParams(Node n1, Node n2, GeneralizedSemPm pm)
    • generateMixedEdgeParams

      public static double[] generateMixedEdgeParams(double w, int L)
    • allEdgeStats

      public static int[][] allEdgeStats(Graph pT, Graph pE)
    • allEdgeStats

      public static int[][] allEdgeStats(Graph pT, Graph pE, HashMap<String,String> nodeDists)
    • makeMixedGraph

      public static Graph makeMixedGraph(Graph g, Map<String,Integer> m)
    • stringFrom2dArray

      public static String stringFrom2dArray(int[][] arr)
    • loadDataSet

      public static DataSet loadDataSet(String dir, String filename) throws IOException
      Throws:
      IOException
    • loadDelim

      public static DataSet loadDelim(String dir, String filename) throws IOException
      Throws:
      IOException
    • getNodeDists

      public static Map<String,Integer> getNodeDists(Graph g)
    • loadData

      public static DataSet loadData(String dir, String filename) throws IOException
      Throws:
      IOException
    • isColinear

      public static boolean isColinear(DataSet ds, boolean verbose)
      Check each pair of variables to see if correlation is 1. WARNING: calculates correlation matrix, memory heavy when there are lots of variables
      Parameters:
      ds -
      verbose -
      Returns:
    • graphToMatrix

      public static cern.colt.matrix.DoubleMatrix2D graphToMatrix(Graph graph, double undirectedWeight, double directedWeight)
    • skeletonToMatrix

      public static cern.colt.matrix.DoubleMatrix2D skeletonToMatrix(Graph graph)
    • graphToMatrix

      public static cern.colt.matrix.DoubleMatrix2D graphToMatrix(Graph graph)
    • IndTestFromString

      public static IndependenceTest IndTestFromString(String name, DataSet data, double alpha)
      Returns independence tests by name located in edu.cmu.tetrad.search and edu.pitt.csb.mgm also supports shorthand for LRT ("lrt) and t-tests ("tlin" for prefer linear (fastest) or "tlog" for prefer logistic)
      Parameters:
      name -
      Returns:
    • main

      public static void main(String[] args)