Package edu.pitt.csb.mgm
Class MixedUtils
java.lang.Object
edu.pitt.csb.mgm.MixedUtils
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final String
ConstantEdgeStatHeader="TD\tTU\tFL\tFD\tFU\tFPD\tFPU\tFND\tFNU\"{trunked}
-
Method Summary
Modifier 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 DataSet
Makes a deep copy of a dataset (Nodes copied as well).static double[]
evenSplitVector
(double w, int L) evenSplitVector.static GeneralizedSemIm
GaussianCategoricalIm.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.static GeneralizedSemPm
GaussianCategoricalPm
(Graph trueGraph, String paramTemplate) GaussianCategoricalPm.static GeneralizedSemPm
GaussianTrinaryPm
(Graph trueGraph, HashMap<String, String> nodeDists, int maxSample, String paramTemplate) GaussianTrinaryPm.static double[]
generateMixedEdgeParams
(double w, int L) generateMixedEdgeParams.static DataSet
getContinousData.static int[]
getContinuousInds
(List<Node> nodes) getContinuousInds.static int[]
getDiscLevels
(DataSet ds) getDiscLevels.static DataSet
getDiscreteData.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.DoubleMatrix2D
graphToMatrix
(Graph graph) graphToMatrix.static cern.colt.matrix.DoubleMatrix2D
graphToMatrix
(Graph graph, double undirectedWeight, double directedWeight) graphToMatrix.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)static boolean
isColinear
(DataSet ds, boolean verbose) Check each pair of variables to see if correlation is 1.static DataSet
loadData.static DataSet
loadDataSet
(String dir, String filename) loadDataSet.static DataSet
loadDelim.static void
main.static DataSet
makeContinuousData
(DataSet dsMix) makeContinuousData.static DataSet
makeMixedData
(DataSet dsCont, Map<String, Integer> nodeDists) makeMixedData.static DataSet
makeMixedData
(DataSet dsCont, Map<String, String> nodeDists, int numCategories) makeMixedData.static Graph
makeMixedGraph
(Graph g, Map<String, Integer> m) makeMixedGraph.static double
numVals
(cern.colt.matrix.DoubleMatrix1D vec) numVals.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 parametersstatic cern.colt.matrix.DoubleMatrix2D
skeletonToMatrix
(Graph graph) skeletonToMatrix.static String
stringFrom2dArray
(int[][] arr) stringFrom2dArray.valSet
(cern.colt.matrix.DoubleMatrix1D vec) valSet.static double
vecMax
(cern.colt.matrix.DoubleMatrix1D vec) vecMax.
-
Field Details
-
EdgeStatHeader
ConstantEdgeStatHeader="TD\tTU\tFL\tFD\tFU\tFPD\tFPU\tFND\tFNU\"{trunked}
- See Also:
-
-
Method Details
-
getDiscreteInds
-
getContinuousInds
-
makeContinuousData
-
makeMixedData
-
makeMixedData
-
deepCopy
-
getContinousData
-
getDiscreteData
-
getDiscLevels
-
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
- aDoubleMatrix2D
object- Returns:
- an array of objects
-
vecMax
public static double vecMax(cern.colt.matrix.DoubleMatrix1D vec) vecMax.
- Parameters:
vec
- aDoubleMatrix1D
object- Returns:
- a double
-
numVals
public static double numVals(cern.colt.matrix.DoubleMatrix1D vec) numVals.
- Parameters:
vec
- aDoubleMatrix1D
object- Returns:
- a double
-
valSet
-
GaussianTrinaryPm
public static GeneralizedSemPm GaussianTrinaryPm(Graph trueGraph, HashMap<String, String> nodeDists, int maxSample, String paramTemplate) throws IllegalStateExceptionGaussianTrinaryPm.
- Parameters:
trueGraph
- aGraph
objectnodeDists
- aHashMap
objectmaxSample
- a intparamTemplate
- aString
object- Returns:
- a
GeneralizedSemPm
object - Throws:
IllegalStateException
- if any.
-
GaussianCategoricalPm
public static GeneralizedSemPm GaussianCategoricalPm(Graph trueGraph, String paramTemplate) throws IllegalStateException GaussianCategoricalPm.
- Parameters:
trueGraph
- aGraph
objectparamTemplate
- aString
object- Returns:
- a
GeneralizedSemPm
object - Throws:
IllegalStateException
- if any.
-
setStartsWith
Set all existing parameters that begins with sta to template and also set template for any new parameters- Parameters:
sta
- aString
objecttemplate
- aString
objectpm
- aGeneralizedSemPm
object
-
GaussianCategoricalIm
GaussianCategoricalIm.
- Parameters:
pm
- aGeneralizedSemPm
object- Returns:
- a
GeneralizedSemIm
object
-
GaussianCategoricalIm
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
- aGeneralizedSemPm
objectdiscParamRand
- true for random edge generation behavior, false for deterministic- Returns:
- a
GeneralizedSemIm
object
-
getEdgeParams
getEdgeParams.
- Parameters:
s1
- aString
objects2
- aString
objectpm
- aGeneralizedSemPm
object- Returns:
- a
List
object
-
arrayPermute
public static double[] arrayPermute(double[] a) arrayPermute.
- Parameters:
a
- an array of objects- Returns:
- an array of objects
-
arrayPermute
public static int[] arrayPermute(int[] a) arrayPermute.
- Parameters:
a
- an array of objects- Returns:
- an array of objects
-
evenSplitVector
public static double[] evenSplitVector(double w, int L) evenSplitVector.
- Parameters:
w
- a doubleL
- a int- Returns:
- an array of objects
-
getEdgeParams
getEdgeParams.
- Parameters:
n1
- aNode
objectn2
- aNode
objectpm
- aGeneralizedSemPm
object- Returns:
- a
List
object
-
generateMixedEdgeParams
public static double[] generateMixedEdgeParams(double w, int L) generateMixedEdgeParams.
- Parameters:
w
- a doubleL
- a int- Returns:
- an array of objects
-
allEdgeStats
-
allEdgeStats
-
makeMixedGraph
-
stringFrom2dArray
-
loadDataSet
loadDataSet.
- Parameters:
dir
- aString
objectfilename
- aString
object- Returns:
- a
DataSet
object - Throws:
IOException
- if any.
-
loadDelim
loadDelim.
- Parameters:
dir
- aString
objectfilename
- aString
object- Returns:
- a
DataSet
object - Throws:
IOException
- if any.
-
getNodeDists
-
loadData
loadData.
- Parameters:
dir
- aString
objectfilename
- aString
object- Returns:
- a
DataSet
object - Throws:
IOException
- if any.
-
isColinear
-
graphToMatrix
-
skeletonToMatrix
-
graphToMatrix
-
IndTestFromString
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
- aString
objectdata
- aDataSet
objectalpha
- a double- Returns:
- a
IndependenceTest
object
-
main
-