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);
}
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);
}
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);
}
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();
}
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);
}
Aggregations