Search in sources :

Example 26 with ICovarianceMatrix

use of edu.cmu.tetrad.data.ICovarianceMatrix in project tetrad by cmu-phil.

the class TestSem method constructCovMatrix2.

private ICovarianceMatrix constructCovMatrix2() {
    String[] vars = new String[] { "X1", "X2", "X3", "X4", "X5", "X6", "X7", "X8" };
    int sampleSize = 173;
    double[][] arr = { { 1.0 }, { .215, 1.0 }, { -.164, -.472, 1.0 }, { .112, .079, -.157, 1.0 }, { .034, .121, -.184, .407, 1.0 }, { .101, .197, -.190, .176, .120, 1.0 }, { .071, -.172, .206, -.049, -.084, -.291, 1.0 }, { .043, -.038, -.037, -.062, .028, .166, -.149, 1.0 } };
    double[][] m = MatrixUtils.convertLowerTriangleToSymmetric(arr);
    TetradMatrix m2 = new TetradMatrix(m);
    return new CovarianceMatrix(DataUtils.createContinuousVariables(vars), m2, sampleSize);
}
Also used : TetradMatrix(edu.cmu.tetrad.util.TetradMatrix) CovarianceMatrix(edu.cmu.tetrad.data.CovarianceMatrix) ICovarianceMatrix(edu.cmu.tetrad.data.ICovarianceMatrix)

Example 27 with ICovarianceMatrix

use of edu.cmu.tetrad.data.ICovarianceMatrix in project tetrad by cmu-phil.

the class TestSem method testSet1.

@Test
public void testSet1() {
    Graph graph = constructGraph1();
    SemPm semPm = new SemPm(graph);
    ICovarianceMatrix covMatrix = constructCovMatrix1();
    new SemIm(semPm, covMatrix);
}
Also used : EdgeListGraph(edu.cmu.tetrad.graph.EdgeListGraph) Graph(edu.cmu.tetrad.graph.Graph) ICovarianceMatrix(edu.cmu.tetrad.data.ICovarianceMatrix) Test(org.junit.Test)

Example 28 with ICovarianceMatrix

use of edu.cmu.tetrad.data.ICovarianceMatrix in project tetrad by cmu-phil.

the class TestSem method constructCovMatrix1.

private ICovarianceMatrix constructCovMatrix1() {
    String[] vars = new String[] { "X1", "X2", "X3", "X4", "X5" };
    double[][] arr = { { 1.04408 }, { 0.80915, 1.55607 }, { 0.89296, 1.67375, 2.87584 }, { 2.23792, 2.68536, 3.94996, 7.78259 }, { 1.17516, 1.36337, 1.99039, 4.04533, 3.14922 } };
    double[][] m = MatrixUtils.convertLowerTriangleToSymmetric(arr);
    TetradMatrix m2 = new TetradMatrix(m);
    return new CovarianceMatrix(DataUtils.createContinuousVariables(vars), m2, 1000);
}
Also used : TetradMatrix(edu.cmu.tetrad.util.TetradMatrix) CovarianceMatrix(edu.cmu.tetrad.data.CovarianceMatrix) ICovarianceMatrix(edu.cmu.tetrad.data.ICovarianceMatrix)

Example 29 with ICovarianceMatrix

use of edu.cmu.tetrad.data.ICovarianceMatrix in project tetrad by cmu-phil.

the class TestSemIm method test3.

@Test
public void test3() {
    Graph graph = constructGraph1();
    SemPm semPm = new SemPm(graph);
    SemIm semIm = new SemIm(semPm);
    DataSet dataSetContColumnContinuous = semIm.simulateData(500, false);
    ICovarianceMatrix covMatrix = new CovarianceMatrix(dataSetContColumnContinuous);
    SemEstimator estimator2 = new SemEstimator(covMatrix, semPm);
    estimator2.estimate();
    estimator2.getEstimatedSem();
    SemEstimator estimator3 = new SemEstimator(covMatrix, semPm);
    estimator3.estimate();
    estimator3.getEstimatedSem();
    SemPm semPm4 = new SemPm(graph);
    SemEstimator estimator4 = new SemEstimator(covMatrix, semPm4);
    estimator4.estimate();
    estimator4.getEstimatedSem();
    SemPm semPm5 = new SemPm(graph);
    SemEstimator estimator5 = new SemEstimator(covMatrix, semPm5);
    estimator5.estimate();
    estimator5.getEstimatedSem();
}
Also used : DataSet(edu.cmu.tetrad.data.DataSet) ICovarianceMatrix(edu.cmu.tetrad.data.ICovarianceMatrix) CovarianceMatrix(edu.cmu.tetrad.data.CovarianceMatrix) ICovarianceMatrix(edu.cmu.tetrad.data.ICovarianceMatrix) Test(org.junit.Test)

Example 30 with ICovarianceMatrix

use of edu.cmu.tetrad.data.ICovarianceMatrix in project tetrad by cmu-phil.

the class IndTestTrekSep method indTestSubset.

// ==========================PUBLIC METHODS=============================//
/**
 * Creates a new independence test instance for a subset of the variables.
 */
public IndependenceTest indTestSubset(List<Node> vars) {
    if (vars.isEmpty()) {
        throw new IllegalArgumentException("Subset may not be empty.");
    }
    for (Node var : vars) {
        if (!variables.contains(var)) {
            throw new IllegalArgumentException("All vars must be original vars");
        }
    }
    int[] indices = new int[vars.size()];
    for (int i = 0; i < indices.length; i++) {
        indices[i] = indexMap.get(vars.get(i));
    }
    ICovarianceMatrix newCovMatrix = covMatrix.getSubmatrix(indices);
    double alphaNew = getAlpha();
    return new IndTestTrekSep(newCovMatrix, alphaNew, clustering, latents);
}
Also used : ICovarianceMatrix(edu.cmu.tetrad.data.ICovarianceMatrix) Node(edu.cmu.tetrad.graph.Node)

Aggregations

ICovarianceMatrix (edu.cmu.tetrad.data.ICovarianceMatrix)30 DataSet (edu.cmu.tetrad.data.DataSet)12 CovarianceMatrix (edu.cmu.tetrad.data.CovarianceMatrix)10 ArrayList (java.util.ArrayList)9 DataModel (edu.cmu.tetrad.data.DataModel)8 Node (edu.cmu.tetrad.graph.Node)8 Graph (edu.cmu.tetrad.graph.Graph)7 SemPm (edu.cmu.tetrad.sem.SemPm)5 TetradMatrix (edu.cmu.tetrad.util.TetradMatrix)5 Test (org.junit.Test)5 Parameters (edu.cmu.tetrad.util.Parameters)4 EdgeListGraph (edu.cmu.tetrad.graph.EdgeListGraph)3 SemIm (edu.cmu.tetrad.sem.SemIm)3 DoubleFactory2D (cern.colt.matrix.DoubleFactory2D)2 DoubleMatrix1D (cern.colt.matrix.DoubleMatrix1D)2 DoubleMatrix2D (cern.colt.matrix.DoubleMatrix2D)2 DenseDoubleMatrix1D (cern.colt.matrix.impl.DenseDoubleMatrix1D)2 DenseDoubleMatrix2D (cern.colt.matrix.impl.DenseDoubleMatrix2D)2 Algebra (cern.colt.matrix.linalg.Algebra)2 ColtDataSet (edu.cmu.tetrad.data.ColtDataSet)2