Package edu.pitt.csb.mgm
Class MixedUtils
java.lang.Object
edu.pitt.csb.mgm.MixedUtils
Created by ajsedgewick on 7/29/15.
- Version:
- $Id: $Id
- 
Field SummaryFieldsModifier and TypeFieldDescriptionstatic final StringConstantEdgeStatHeader="TD\tTU\tFL\tFD\tFU\tFPD\tFPU\tFND\tFNU\"{trunked}
- 
Method SummaryModifier and TypeMethodDescriptionstatic int[][]allEdgeStats(Graph pT, Graph pE) allEdgeStats.static int[][]allEdgeStats.static double[]arrayPermute(double[] a) arrayPermute.static int[]arrayPermute(int[] a) arrayPermute.static int[]colMax(cern.colt.matrix.DoubleMatrix2D m) return vector of the maximum of each column in m (as ints, i.e.static DataSetMakes a deep copy of a dataset (Nodes copied as well).static double[]evenSplitVector(double w, int L) evenSplitVector.static GeneralizedSemImGaussianCategoricalIm.static GeneralizedSemImGaussianCategoricalIm(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.static GeneralizedSemPmGaussianCategoricalPm(Graph trueGraph, String paramTemplate) GaussianCategoricalPm.static GeneralizedSemPmGaussianTrinaryPm(Graph trueGraph, HashMap<String, String> nodeDists, int maxSample, String paramTemplate) GaussianTrinaryPm.static double[]generateMixedEdgeParams(double w, int L) generateMixedEdgeParams.static DataSetgetContinousData.static int[]getContinuousInds(List<Node> nodes) getContinuousInds.static int[]getDiscLevels(DataSet ds) getDiscLevels.static DataSetgetDiscreteData.static int[]getDiscreteInds(List<Node> nodes) getDiscreteInds.getEdgeParams(Node n1, Node n2, GeneralizedSemPm pm) getEdgeParams.getEdgeParams(String s1, String s2, GeneralizedSemPm pm) getEdgeParams.getNodeDists.static cern.colt.matrix.DoubleMatrix2DgraphToMatrix(Graph graph) graphToMatrix.static cern.colt.matrix.DoubleMatrix2DgraphToMatrix(Graph graph, double undirectedWeight, double directedWeight) graphToMatrix.static IndependenceTestIndTestFromString(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)static booleanisColinear(DataSet ds, boolean verbose) Check each pair of variables to see if correlation is 1.static DataSetloadData.static DataSetloadDataSet(String dir, String filename) loadDataSet.static DataSetloadDelim.static voidmain.static DataSetmakeContinuousData(DataSet dsMix) makeContinuousData.static DataSetmakeMixedData(DataSet dsCont, Map<String, Integer> nodeDists) makeMixedData.static DataSetmakeMixedData(DataSet dsCont, Map<String, String> nodeDists, int numCategories) makeMixedData.static GraphmakeMixedGraph(Graph g, Map<String, Integer> m) makeMixedGraph.static doublenumVals(cern.colt.matrix.DoubleMatrix1D vec) numVals.static voidsetStartsWith(String sta, String template, GeneralizedSemPm pm) Set all existing parameters that begins with sta to template and also set template for any new parametersstatic cern.colt.matrix.DoubleMatrix2DskeletonToMatrix(Graph graph) skeletonToMatrix.static StringstringFrom2dArray(int[][] arr) stringFrom2dArray.valSet(cern.colt.matrix.DoubleMatrix1D vec) valSet.static doublevecMax(cern.colt.matrix.DoubleMatrix1D vec) vecMax.
- 
Field Details- 
EdgeStatHeaderConstantEdgeStatHeader="TD\tTU\tFL\tFD\tFU\tFPD\tFPU\tFND\tFNU\"{trunked}- See Also:
 
 
- 
- 
Method Details- 
getDiscreteIndsgetDiscreteInds. - Parameters:
- nodes- a- Listobject
- Returns:
- an array of intobjects
 
- 
getContinuousIndsgetContinuousInds. - Parameters:
- nodes- a- Listobject
- Returns:
- an array of intobjects
 
- 
makeContinuousDatamakeContinuousData. 
- 
makeMixedDatapublic static DataSet makeMixedData(DataSet dsCont, Map<String, String> nodeDists, int numCategories) makeMixedData. 
- 
makeMixedDatamakeMixedData. 
- 
deepCopyMakes a deep copy of a dataset (Nodes copied as well). Useful for paralellization- Parameters:
- ds- dataset to be copied
- Returns:
- a DataSetobject
 
- 
getContinousDatagetContinousData. 
- 
getDiscreteDatagetDiscreteData. 
- 
getDiscLevelsgetDiscLevels. - Parameters:
- ds- a- DataSetobject
- Returns:
- an array of intobjects
 
- 
colMaxpublic 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- a- DoubleMatrix2Dobject
- Returns:
- an array of intobjects
 
- 
vecMaxpublic static double vecMax(cern.colt.matrix.DoubleMatrix1D vec) vecMax. - Parameters:
- vec- a- DoubleMatrix1Dobject
- Returns:
- a double
 
- 
numValspublic static double numVals(cern.colt.matrix.DoubleMatrix1D vec) numVals. - Parameters:
- vec- a- DoubleMatrix1Dobject
- Returns:
- a double
 
- 
valSetvalSet. - Parameters:
- vec- a- DoubleMatrix1Dobject
- Returns:
- a Setobject
 
- 
GaussianTrinaryPmpublic static GeneralizedSemPm GaussianTrinaryPm(Graph trueGraph, HashMap<String, String> nodeDists, int maxSample, String paramTemplate) throws IllegalStateExceptionGaussianTrinaryPm. - Parameters:
- trueGraph- a- Graphobject
- nodeDists- a- HashMapobject
- maxSample- a int
- paramTemplate- a- Stringobject
- Returns:
- a GeneralizedSemPmobject
- Throws:
- IllegalStateException- if any.
 
- 
GaussianCategoricalPmpublic static GeneralizedSemPm GaussianCategoricalPm(Graph trueGraph, String paramTemplate) throws IllegalStateException GaussianCategoricalPm. - Parameters:
- trueGraph- a- Graphobject
- paramTemplate- a- Stringobject
- Returns:
- a GeneralizedSemPmobject
- Throws:
- IllegalStateException- if any.
 
- 
setStartsWithSet all existing parameters that begins with sta to template and also set template for any new parameters- Parameters:
- sta- a- Stringobject
- template- a- Stringobject
- pm- a- GeneralizedSemPmobject
 
- 
GaussianCategoricalImGaussianCategoricalIm. - Parameters:
- pm- a- GeneralizedSemPmobject
- Returns:
- a GeneralizedSemImobject
 
- 
GaussianCategoricalImThis 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- a- GeneralizedSemPmobject
- discParamRand- true for random edge generation behavior, false for deterministic
- Returns:
- a GeneralizedSemImobject
 
- 
getEdgeParamsgetEdgeParams. - Parameters:
- s1- a- Stringobject
- s2- a- Stringobject
- pm- a- GeneralizedSemPmobject
- Returns:
- a Listobject
 
- 
arrayPermutepublic static double[] arrayPermute(double[] a) arrayPermute. - Parameters:
- a- an array of- doubleobjects
- Returns:
- an array of doubleobjects
 
- 
arrayPermutepublic static int[] arrayPermute(int[] a) arrayPermute. - Parameters:
- a- an array of- intobjects
- Returns:
- an array of intobjects
 
- 
evenSplitVectorpublic static double[] evenSplitVector(double w, int L) evenSplitVector. - Parameters:
- w- a double
- L- a int
- Returns:
- an array of doubleobjects
 
- 
getEdgeParamsgetEdgeParams. - Parameters:
- n1- a- Nodeobject
- n2- a- Nodeobject
- pm- a- GeneralizedSemPmobject
- Returns:
- a Listobject
 
- 
generateMixedEdgeParamspublic static double[] generateMixedEdgeParams(double w, int L) generateMixedEdgeParams. - Parameters:
- w- a double
- L- a int
- Returns:
- an array of doubleobjects
 
- 
allEdgeStatsallEdgeStats. 
- 
allEdgeStatsallEdgeStats. 
- 
makeMixedGraphmakeMixedGraph. 
- 
stringFrom2dArraystringFrom2dArray. - Parameters:
- arr- an array of- intobjects
- Returns:
- a Stringobject
 
- 
loadDataSetloadDataSet. - Parameters:
- dir- a- Stringobject
- filename- a- Stringobject
- Returns:
- a DataSetobject
- Throws:
- IOException- if any.
 
- 
loadDelimloadDelim. - Parameters:
- dir- a- Stringobject
- filename- a- Stringobject
- Returns:
- a DataSetobject
- Throws:
- IOException- if any.
 
- 
getNodeDistsgetNodeDists. 
- 
loadDataloadData. - Parameters:
- dir- a- Stringobject
- filename- a- Stringobject
- Returns:
- a DataSetobject
- Throws:
- IOException- if any.
 
- 
isColinearCheck each pair of variables to see if correlation is 1. WARNING: calculates correlation matrix, memory heavy when there are lots of variables- Parameters:
- ds- a- DataSetobject
- verbose- a boolean
- Returns:
- a boolean
 
- 
graphToMatrixpublic static cern.colt.matrix.DoubleMatrix2D graphToMatrix(Graph graph, double undirectedWeight, double directedWeight) graphToMatrix. - Parameters:
- graph- a- Graphobject
- undirectedWeight- a double
- directedWeight- a double
- Returns:
- a DoubleMatrix2Dobject
 
- 
skeletonToMatrixskeletonToMatrix. - Parameters:
- graph- a- Graphobject
- Returns:
- a DoubleMatrix2Dobject
 
- 
graphToMatrixgraphToMatrix. - Parameters:
- graph- a- Graphobject
- Returns:
- a DoubleMatrix2Dobject
 
- 
IndTestFromStringReturns 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- a- Stringobject
- data- a- DataSetobject
- alpha- a double
- Returns:
- a IndependenceTestobject
 
- 
mainmain. - Parameters:
- args- an array of- Stringobjects
 
 
-