示例#1
0
  private static String get_fixed(Tgm tgm) {
    String fixedStr = null;
    KinparPanelModel kinparPanelModel = tgm.getDat().getKinparPanel();
    int count = 0;
    for (int i = 0; i < kinparPanelModel.getKinpar().size(); i++) {
      if (kinparPanelModel.getKinpar().get(i).isFixed()) {
        if (count > 0) {
          fixedStr = fixedStr + ",";
        } else {
          fixedStr = "fixed = list(kinpar=c(";
        }
        fixedStr = fixedStr + String.valueOf(i + 1);
        count++;
      }
    }
    if (count > 0) {
      fixedStr = fixedStr + ")";
    }

    count = 0;

    KMatrixPanelModel kmatPanel = tgm.getDat().getKMatrixPanel();
    for (int i = 0; i < kmatPanel.getKinScal().size(); i++) {
      if (kmatPanel.getKinScal().get(i).isFixed()) {
        if (count > 0) {
          fixedStr = fixedStr + ",";
        } else {
          if (fixedStr != null) {
            fixedStr = fixedStr + ", kinscal=c(";
          } else {
            fixedStr = "fixed = list(kinscal=c(";
          }
        }
        fixedStr = fixedStr + String.valueOf(i + 1);
        count++;
      }
    }
    if (count > 0) {
      fixedStr = fixedStr + ")";
    }

    count = 0;
    IrfparPanelModel irfPanel = tgm.getDat().getIrfparPanel();
    for (int i = 0; i < irfPanel.getFixed().size(); i++) {
      if (irfPanel.getFixed().get(i)) {
        if (count > 0) {
          fixedStr = fixedStr + ",";
        } else {
          if (fixedStr != null) {
            fixedStr = fixedStr + ", irfpar=c(";
          } else {
            fixedStr = "fixed = list(irfpar=c(";
          }
        }
        fixedStr = fixedStr + String.valueOf(i + 1);
        count++;
      }
    }
    if (count > 0) {
      fixedStr = fixedStr + ")";
    }

    if (irfPanel.getParmu() != null) {
      if (irfPanel.isParmufixed() != null && irfPanel.isParmufixed()) {
        if (fixedStr != null) {
          fixedStr = fixedStr + ", parmu=c(";
        } else {
          fixedStr = "fixed = list(parmu=c(";
        }

        String[] doubles = irfPanel.getParmu().split(",");
        fixedStr = fixedStr + "1:" + String.valueOf(doubles.length);
        fixedStr = fixedStr + ")";
      }
    }

    if (irfPanel.getPartau() != null) {
      if (irfPanel.isPartaufixed()) {
        if (fixedStr != null) {
          fixedStr = fixedStr + ", partau=c(";
        } else {
          fixedStr = "fixed = list(partau=c(";
        }

        String[] doubles = irfPanel.getPartau().split(",");
        fixedStr = fixedStr + "1:" + String.valueOf(doubles.length);
        fixedStr = fixedStr + ")";
      }
    }
    count = 0;
    for (int i = 0; i < tgm.getDat().getCohspecPanel().getCohspec().getFixed().size(); i++) {
      if (tgm.getDat().getCohspecPanel().getCohspec().getFixed().get(i)) {
        if (count > 0) {
          fixedStr = fixedStr + ",";
        } else {
          if (fixedStr != null) {
            fixedStr = fixedStr + ", coh=c(";
          } else {
            fixedStr = "fixed = list(coh=c(";
          }
        }
        fixedStr = fixedStr + String.valueOf(i + 1);
        count++;
      }
    }
    if (count > 0) {
      fixedStr = fixedStr + ")";
    }

    if (tgm.getDat().getOscspecPanel() != null) {
      if (tgm.getDat().getOscspecPanel().getOscspec() != null) {
        count = 0;
        for (int i = 0; i < tgm.getDat().getOscspecPanel().getOscspec().getFixed().size(); i++) {
          if (tgm.getDat().getOscspecPanel().getOscspec().getFixed().get(i)) {
            if (count > 0) {
              fixedStr = fixedStr + ",";
            } else {
              if (fixedStr != null) {
                fixedStr = fixedStr + ", oscpar=c(";
              } else {
                fixedStr = "fixed = list(oscpar=c(";
              }
            }
            fixedStr = fixedStr + String.valueOf(i + 1);
            count++;
          }
        }
        if (count > 0) {
          fixedStr = fixedStr + ")";
        }
      }
    }

    count = 0;
    KMatrixPanelModel kMatrix = tgm.getDat().getKMatrixPanel();
    for (int i = 0; i < kMatrix.getJVector().getFixed().size(); i++) {
      if (kMatrix.getJVector().getFixed().get(i)) {
        if (count > 0) {
          fixedStr = fixedStr + ",";
        } else {
          if (fixedStr != null) {
            fixedStr = fixedStr + ", jvec=c(";
          } else {
            fixedStr = "fixed = list(jvec=c(";
          }
        }
        fixedStr = fixedStr + String.valueOf(i + 1);
        count++;
      }
    }
    if (count > 0) {
      fixedStr = fixedStr + ")";
    }
    // TODO: add additional paramters for fixed here:

    // This closes the "fixed" argument
    if (fixedStr != null) {
      if (addToFixed != null) {
        fixedStr = fixedStr + "," + addToFixed + ")";
      } else {
        fixedStr = fixedStr + ")";
      }
    } else {
      if (addToFixed != null) {
        fixedStr = "fixed = list(" + addToFixed + ")";
      }
    }

    return fixedStr;
  }
示例#2
0
  // Private classes
  public static String get_kmatrix(Tgm tgm) {
    String kMatrixCall = null;

    KMatrixPanelModel kMatrix = tgm.getDat().getKMatrixPanel();

    int matrixSize = kMatrix.getJVector().getVector().size();
    if (matrixSize > 0) {
      kMatrixCall = "kmat = array(c(";
      kMatrixCall =
          kMatrixCall.concat(String.valueOf(kMatrix.getKMatrix().getData().get(0).getRow().get(0)));
      for (int j = 1; j < matrixSize; j++) {
        kMatrixCall =
            kMatrixCall.concat(
                "," + String.valueOf(kMatrix.getKMatrix().getData().get(j).getRow().get(0)));
      }
      for (int i = 1; i < matrixSize; i++) {
        for (int j = 0; j < matrixSize; j++) {
          kMatrixCall =
              kMatrixCall.concat(
                  "," + String.valueOf(kMatrix.getKMatrix().getData().get(j).getRow().get(i)));
        }
      }
      for (int i = 0; i < matrixSize; i++) {
        for (int j = 0; j < matrixSize; j++) {
          kMatrixCall =
              kMatrixCall.concat(
                  ","
                      + String.valueOf(
                          kMatrix.getKMatrix().getData().get(j + matrixSize).getRow().get(i)));
        }
      }

      kMatrixCall = kMatrixCall.concat("), dim = c(");
      kMatrixCall =
          kMatrixCall.concat(
              String.valueOf(matrixSize) + "," + String.valueOf(matrixSize) + ",2))");
      kMatrixCall = kMatrixCall.concat(", jvec = c(");
      // TODO: verify jVector
      kMatrixCall = kMatrixCall.concat(String.valueOf(kMatrix.getJVector().getVector().get(0)));
      for (int j = 1; j < matrixSize; j++) {
        kMatrixCall =
            kMatrixCall.concat("," + String.valueOf(kMatrix.getJVector().getVector().get(j)));
      }
      kMatrixCall = kMatrixCall.concat(")");

      int size = kMatrix.getKinScal().size();
      if (size > 0) {
        kMatrixCall = kMatrixCall.concat(", kinscal = c(");
        double k;
        for (int i = 0; i < size; i++) {
          if (i > 0) {
            kMatrixCall = kMatrixCall + ",";
          }
          k = kMatrix.getKinScal().get(i).getStart();
          kMatrixCall = kMatrixCall + Double.toString(k);
        }
        kMatrixCall = kMatrixCall + ")";
      }
    }
    return kMatrixCall;
  }