Search in sources :

Example 1 with ScoreType

use of edu.cmu.tetrad.sem.ScoreType in project tetrad by cmu-phil.

the class SemEstimatorWrapper method setParams.

private boolean setParams(SemPmWrapper semPmWrapper, DataModelList dataModel) {
    for (DataModel model : dataModel) {
        if (model instanceof DataSet) {
            DataSet dataSet = (DataSet) model;
            SemPm semPm = semPmWrapper.getSemPm();
            this.semPm = semPm;
            SemEstimator estimator = new SemEstimator(dataSet, semPm, getOptimizer());
            estimator.setNumRestarts(getParams().getInt("numRestarts", 1));
            estimator.setScoreType((ScoreType) getParams().get("scoreType", ScoreType.Fgls));
            if (!degreesOfFreedomCheck(semPm)) {
                return true;
            }
            estimator.estimate();
            getMultipleResultList().add(estimator);
        } else if (model instanceof ICovarianceMatrix) {
            ICovarianceMatrix covMatrix = new CovarianceMatrix((ICovarianceMatrix) model);
            SemPm semPm = semPmWrapper.getSemPm();
            this.semPm = semPm;
            SemEstimator estimator = new SemEstimator(covMatrix, semPm, getOptimizer());
            estimator.setNumRestarts(getParams().getInt("numRestarts", 1));
            estimator.setScoreType((ScoreType) getParams().get("scoreType", ScoreType.Fgls));
            if (!degreesOfFreedomCheck(semPm)) {
                return true;
            }
            estimator.estimate();
            getMultipleResultList().add(estimator);
        } else {
            throw new IllegalArgumentException("Data must consist of continuous data sets or covariance matrices.");
        }
    }
    return false;
}
Also used : ColtDataSet(edu.cmu.tetrad.data.ColtDataSet) DataSet(edu.cmu.tetrad.data.DataSet) DataModel(edu.cmu.tetrad.data.DataModel) ICovarianceMatrix(edu.cmu.tetrad.data.ICovarianceMatrix) SemPm(edu.cmu.tetrad.sem.SemPm) SemEstimator(edu.cmu.tetrad.sem.SemEstimator) ScoreType(edu.cmu.tetrad.sem.ScoreType) ICovarianceMatrix(edu.cmu.tetrad.data.ICovarianceMatrix) CovarianceMatrix(edu.cmu.tetrad.data.CovarianceMatrix)

Aggregations

ColtDataSet (edu.cmu.tetrad.data.ColtDataSet)1 CovarianceMatrix (edu.cmu.tetrad.data.CovarianceMatrix)1 DataModel (edu.cmu.tetrad.data.DataModel)1 DataSet (edu.cmu.tetrad.data.DataSet)1 ICovarianceMatrix (edu.cmu.tetrad.data.ICovarianceMatrix)1 ScoreType (edu.cmu.tetrad.sem.ScoreType)1 SemEstimator (edu.cmu.tetrad.sem.SemEstimator)1 SemPm (edu.cmu.tetrad.sem.SemPm)1