private static Element makeVariables(SemIm semIm) { Element variablesElement = new Element(SemXmlConstants.SEM_VARIABLES); Element variable; Node measuredNode, latentNode; for (Node node1 : semIm.getSemPm().getMeasuredNodes()) { measuredNode = node1; variable = new Element(SemXmlConstants.CONTINUOUS_VARIABLE); variable.addAttribute(new Attribute(SemXmlConstants.NAME, measuredNode.getName())); variable.addAttribute(new Attribute(SemXmlConstants.IS_LATENT, "no")); variable.addAttribute( new Attribute(SemXmlConstants.MEAN, Double.toString(semIm.getMean(measuredNode)))); variable.addAttribute( new Attribute(SemXmlConstants.X, Integer.toString(measuredNode.getCenterX()))); variable.addAttribute( new Attribute(SemXmlConstants.Y, Integer.toString(measuredNode.getCenterY()))); variablesElement.appendChild(variable); } for (Node node : semIm.getSemPm().getLatentNodes()) { latentNode = node; variable = new Element(SemXmlConstants.CONTINUOUS_VARIABLE); variable.addAttribute(new Attribute(SemXmlConstants.NAME, latentNode.getName())); variable.addAttribute(new Attribute(SemXmlConstants.IS_LATENT, "yes")); variable.addAttribute( new Attribute(SemXmlConstants.MEAN, Double.toString(semIm.getMean(latentNode)))); variable.addAttribute( new Attribute(SemXmlConstants.X, Integer.toString(latentNode.getCenterX()))); variable.addAttribute( new Attribute(SemXmlConstants.Y, Integer.toString(latentNode.getCenterY()))); variablesElement.appendChild(variable); } return variablesElement; }
private String compileReport() { StringBuilder builder = new StringBuilder(); builder.append("Datset\tFrom\tTo\tType\tValue\tSE\tT\tP"); java.util.List<SemEstimator> estimators = wrapper.getMultipleResultList(); for (int i = 0; i < estimators.size(); i++) { SemEstimator estimator = estimators.get(i); SemIm estSem = estimator.getEstimatedSem(); String dataName = estimator.getDataSet().getName(); for (Parameter parameter : estSem.getFreeParameters()) { builder.append("\n"); builder.append(dataName + "\t"); builder.append(parameter.getNodeA() + "\t"); builder.append(parameter.getNodeB() + "\t"); builder.append(typeString(parameter) + "\t"); builder.append(asString(paramValue(estSem, parameter)) + "\t"); /* Maximum number of free parameters for which statistics will be calculated. (Calculating standard errors is high complexity.) Set this to zero to turn off statistics calculations (which can be problematic sometimes). */ int maxFreeParamsForStatistics = 200; builder.append( asString(estSem.getStandardError(parameter, maxFreeParamsForStatistics)) + "\t"); builder.append(asString(estSem.getTValue(parameter, maxFreeParamsForStatistics)) + "\t"); builder.append(asString(estSem.getPValue(parameter, maxFreeParamsForStatistics)) + "\t"); } List<Node> nodes = estSem.getVariableNodes(); for (int j = 0; j < nodes.size(); j++) { Node node = nodes.get(j); int n = estSem.getSampleSize(); int df = n - 1; double mean = estSem.getMean(node); double stdDev = estSem.getMeanStdDev(node); double stdErr = stdDev / Math.sqrt(n); double tValue = mean / stdErr; double p = 2.0 * (1.0 - ProbUtils.tCdf(Math.abs(tValue), df)); builder.append("\n"); builder.append(dataName + "\t"); builder.append(nodes.get(j) + "\t"); builder.append(nodes.get(j) + "\t"); builder.append("Mean" + "\t"); builder.append(asString(mean) + "\t"); builder.append(asString(stdErr) + "\t"); builder.append(asString(tValue) + "\t"); builder.append(asString(p) + "\t"); } } return builder.toString(); }