Package edu.pitt.csb.mgm
Class MixedUtils
java.lang.Object
edu.pitt.csb.mgm.MixedUtils
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringConstantEdgeStatHeader="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 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
-
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- aDoubleMatrix2Dobject- Returns:
- an array of objects
-
vecMax
public static double vecMax(cern.colt.matrix.DoubleMatrix1D vec) vecMax.
- Parameters:
vec- aDoubleMatrix1Dobject- Returns:
- a double
-
numVals
public static double numVals(cern.colt.matrix.DoubleMatrix1D vec) numVals.
- Parameters:
vec- aDoubleMatrix1Dobject- Returns:
- a double
-
valSet
-
GaussianTrinaryPm
public static GeneralizedSemPm GaussianTrinaryPm(Graph trueGraph, HashMap<String, String> nodeDists, int maxSample, String paramTemplate) throws IllegalStateExceptionGaussianTrinaryPm.
- Parameters:
trueGraph- aGraphobjectnodeDists- aHashMapobjectmaxSample- a intparamTemplate- aStringobject- Returns:
- a
GeneralizedSemPmobject - Throws:
IllegalStateException- if any.
-
GaussianCategoricalPm
public static GeneralizedSemPm GaussianCategoricalPm(Graph trueGraph, String paramTemplate) throws IllegalStateException GaussianCategoricalPm.
- Parameters:
trueGraph- aGraphobjectparamTemplate- aStringobject- Returns:
- a
GeneralizedSemPmobject - 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- aStringobjecttemplate- aStringobjectpm- aGeneralizedSemPmobject
-
GaussianCategoricalIm
GaussianCategoricalIm.
- Parameters:
pm- aGeneralizedSemPmobject- Returns:
- a
GeneralizedSemImobject
-
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- aGeneralizedSemPmobjectdiscParamRand- true for random edge generation behavior, false for deterministic- Returns:
- a
GeneralizedSemImobject
-
getEdgeParams
getEdgeParams.
- Parameters:
s1- aStringobjects2- aStringobjectpm- aGeneralizedSemPmobject- Returns:
- a
Listobject
-
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- aNodeobjectn2- aNodeobjectpm- aGeneralizedSemPmobject- Returns:
- a
Listobject
-
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- aStringobjectfilename- aStringobject- Returns:
- a
DataSetobject - Throws:
IOException- if any.
-
loadDelim
loadDelim.
- Parameters:
dir- aStringobjectfilename- aStringobject- Returns:
- a
DataSetobject - Throws:
IOException- if any.
-
getNodeDists
-
loadData
loadData.
- Parameters:
dir- aStringobjectfilename- aStringobject- Returns:
- a
DataSetobject - 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- aStringobjectdata- aDataSetobjectalpha- a double- Returns:
- a
IndependenceTestobject
-
main
-