⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 status.cc

📁 统计模块的 C++源程序 ,可以用来计算统计数据. 
💻 CC
📖 第 1 页 / 共 2 页
字号:
      cerr << "Error, status::to, Error writing to " << filename << "\n";
      exit(1);
    }
  }

  sprintf(temp,"%-19s", method);
  if (!(oto<<temp<< "What estimation method?  Code SUR, TSLS, or GMM.\n")) {
    cerr << "Error, status::to, Error writing to " << filename << "\n";
    exit(1);
  }

  sprintf(temp,"%-19d", n);
  if (!(oto<<temp<< "Number of observations, t = 1, ..., n.\n")) {
    cerr << "Error, status::to, Error writing to " << filename << "\n";
    exit(1);
  }

  sprintf(temp,"%-19d",M);
  if (!(oto<<temp<<"Number of equations, i.e. dimension of e.\n")) {
    cerr << "Error, status::to, Error writing to " << filename << "\n";
    exit(1);
  }

  sprintf(temp,"%-19d",K);
  if (!(oto<<temp<<"Number of instruments, i.e. dimension of Z.\n")) {
    cerr << "Error, status::to, Error writing to " << filename << "\n";
    exit(1);
  }

  sprintf(temp,"%-19d",p);
  if (!(oto<<temp<< "Number of parameters, i.e. dimension of theta.\n")){
    cerr << "Error, status::to, Error writing to " << filename << "\n";
    exit(1);
  }

  sprintf(temp,"%-19d",itheta);
  if (!(oto<<temp<< "Upper limit on Gauss-Newton iterations.\n")) {
    cerr << "Error, status::to, Error writing to " << filename << "\n";
    exit(1);
  }

  sprintf(temp,"%-19d",ivar);
  if (!(oto<<temp<< "Number var iterates, ivar=0 means none.\n")) {
    cerr << "Error, status::to, Error writing to " << filename << "\n";
    exit(1);
  }

  sprintf(temp,"%-19s",vartype);
  if (!(oto<<temp<< "Code homoskedastic or heteroskedastic.\n")) {
    cerr << "Error, status::to, Error writing to " << filename << "\n";
    exit(1);
  }
  sprintf(temp,"%-19d",MA);
  if (!(oto<<temp<< "Number of moving average terms MA for var estimate.\n")) {
    cerr << "Error, status::to, Error writing to " << filename << "\n";
    exit(1);
  }

  sprintf(temp,"%-19s",weights);
  if (!(oto<<temp<<"Code none or Parzen, none when MA>0 is unwise.\n")) {
    cerr << "Error, status::to, Error writing to " << filename << "\n";
    exit(1);
  }

  sprintf(temp,"%-19.6e",tol);
  if (!(oto<<temp<< "Convergence tolerance, tol=1.0e-8 is reasonable.\n")) {
    cerr << "Error, status::to, Error writing to " << filename << "\n";
    exit(1);
  }

  sprintf(temp,"%-19.6e",eps);
  if (!(oto<<temp<< "Inversion tolerance, eps=1.0e-13 is reasonable\n")) {
    cerr << "Error, status::to, Error writing to " << filename << "\n";
    exit(1);                   
  }

  sprintf(temp,"%-19s",detail);
  if (!(oto<<temp<<"How much output?  Code none, minimal, or full.\n")) {
    cerr << "Error, status::to, Error writing to " << filename << "\n";
    exit(1);
  }

  sprintf(temp,"%-19d",rank);
  if (!(oto<<temp<< "Computed rank of V.\n")) {
    cerr << "Error, status::to, Error writing to " << filename << "\n";
    exit(1);
  }

  sprintf(temp,"%-19s",df);
  if (!(oto<<temp<< "Divisor of var, corrected or uncorrected.\n")) {
    cerr << "Error, status::to, Error writing to " << filename << "\n";
    exit(1);
  }

  for (i=3; i<=5; i++) {
    if (!(oto << "                   Blank line.\n")) {
      cerr << "Error, status::to, Error writing to " << filename << "\n";
      exit(1);
    }
  }

  if ( rows(theta) <= 0 || cols(theta) <= 0 ){
    cerr << "Error, status::to, theta is not initialized.\n";
    exit(1);
  }

  for (i=1; i<=p; i++) {
    sprintf(temp,"%25.16e % 20.8f ",theta[i],theta[i]);
    if(!(oto<<temp<< " theta(" << i << ")\n")) {
      cerr << "Error, status::to, Error writing to " << filename << "\n";
      exit(1);
    }
  }

  if ( rows(var) <= 0 || cols(var) <= 0 ){
    cerr << "Warning, status::to, var is not initialized, " << filename
         << " incomplete.\n";
    return 0;
  }

  if ( strcmp(method,"SUR") == 0 || strcmp(method,"TSLS") == 0) {
    for (j=1; j<=M; j++) { 
    for (i=1; i<=M; i++) { 
      sprintf(temp,"%25.16e % 20.8f ",var.check2(i,j),var.elem(i,j));
      if(!(oto<<temp<< " var(" << i << "," << j << ")\n")) {
        cerr << "Error, status::to, Error writing to " << filename << "\n";
        exit(1);
      }
    }
    }  
  }
  else {
    len = M*K;
    for (j=1; j<=len; j++) {
    for (i=1; i<=len; i++) {
      sprintf(temp,"%25.16e % 20.8f ",var.check2(i,j),var.elem(i,j));
      if(!(oto<<temp<< " var(" << i << "," << j << ")\n")) {
        cerr << "Error, status::to, Error writing to " << filename << "\n";
        exit(1);
      }
    }
    }
  }

  if ( rows(V) <= 0 || cols(V) <= 0 ){
    cerr << "Warning, status::to, V is not initialized, file incomplete.\n";
    return 0;
  }

  for (j=1; j<=p; j++) {
  for (i=1; i<=p; i++) {
    sprintf(temp,"%25.16e % 20.8f ",V.check2(i,j),V.elem(i,j));
    if(!(oto<<temp<< " V(" << i << "," << j << ")\n" )) {
      cerr << "Error, status::to, Error writing to " << filename << "\n";
      exit(1);
    }
  }
  }


  if ( rows(D) <= 0 || cols(D) <= 0 ){
    cerr << "Error, status::to, D is not initialized.\n";
    exit(1);
  }

  for (i=1; i<=p; i++) {
    sprintf(temp,"%25.16e % 20.8f ",D[i],D[i]);
    if(!(oto<<temp<< " D(" << i << ")\n")) {
      cerr << "Error, status::to, Error writing to " << filename << "\n";
      exit(1);
    }
  }


  sprintf(temp,"%25.16e % 20.8f ",obj,obj);
  if (!(oto<<temp<< " obj\n")) {
    cerr << "Error, status::to, Error writing to " << filename << "\n";
    exit(1);
  }

  oto.close();
  return 0;

}

int status::display(display_mode mode)
{

  INTEGER i,j,len;
  char    temp[MAX_STATUS_LINE];
  char*   pad = "     ";


  switch (mode) {

  case START_UP:

    cout << starbox("/Parameter settings//_") << "\n";

    cout<<pad<< switches << "\n";

    sprintf(temp,"%-19s", method);
    cout<<pad<<temp<< "What estimation method?  Code SUR, TSLS, or GMM.\n";

    sprintf(temp,"%-19d", n);
    cout<<pad<<temp<< "Number of observations, t = 1, ..., n.\n";

    sprintf(temp,"%-19d",M);
    cout<<pad<<temp<< "Number of equations, i.e. dimension of e.\n";

    sprintf(temp,"%-19d",K);
    cout<<pad<<temp<<"Number of instruments, i.e. dimension of Z.\n";

    sprintf(temp,"%-19d",p);
    cout<<pad<<temp<<"Number of parameters, i.e. dimension of theta.\n";

    sprintf(temp,"%-19d",itheta);
    cout<<pad<<temp<< "Upper limit on Gauss-Newton iterations.\n";

    sprintf(temp,"%-19d",ivar);
    cout<<pad<<temp<< "Number var iterates, ivar=0 means none.\n";

    sprintf(temp,"%-19s",vartype);
    cout<<pad<<temp<< "Code homoskedastic or heteroskedastic.\n";

    sprintf(temp,"%-19d",MA);
    cout<<pad<<temp<< "Number of moving average terms MA for var estimate.\n";

    sprintf(temp,"%-19s",weights);
    cout<<pad<<temp<< "Code none or Parzen, none when MA>0 is unwise.\n";

    sprintf(temp,"%-19.6e",tol);
    cout<<pad<<temp<< "Convergence tolerance, tol=1.0e-8 is reasonable.\n";

    sprintf(temp,"%-19.6e",eps);
    cout<<pad<<temp<< "Inversion tolerance, eps=1.0e-13 is reasonable\n";

    sprintf(temp,"%-19s",detail);
    cout<<pad<<temp<< "How much output?  Code none, minimal, or full.\n";

    break;

  case VAR_ITERATE:

    if ( rows(var) > 0 && cols(var) > 0 ){
      if ( strcmp(method,"SUR") == 0 || strcmp(method,"TSLS") == 0){
        for (j=1; j<=M; j++){ 
        for (i=1; i<=M; i++){ 
          sprintf(temp,"%25.16e % 20.8f ",var.check2(i,j),var.elem(i,j));
          cout<<temp<< " var(" << i << "," << j << ")\n";
        }
        }  
      }
      else{
        len = M*K;
        for (j=1; j<=len; j++){
        for (i=1; i<=len; i++){
          sprintf(temp,"%25.16e % 20.8f ",var.check2(i,j),var.elem(i,j));
          cout<<temp<< " var(" << i << "," << j << ")\n";
        }
        }
      }
    }
    else{
      cout << "Error, status::display, var is not initialized.\n";
    }

    break;

   case THETA_ITERATE:

    if ( rows(theta) > 0 && cols(theta) > 0 ){
      for (i=1; i<=p; i++){
        sprintf(temp,"%25.16e % 20.8f ",theta[i],theta[i]);
        cout<<temp<< " theta(" << i << ")\n";
      }
    }
    else{
      cout << "Error, status::display, theta is not initialized.\n";
    }

    sprintf(temp,"%25.16e % 20.8f ",obj,obj);
    cout<<temp<< " obj\n";

    if (strcmp(detail,"full")!=0) break;

    if ( rows(D) > 0 && cols(D) > 0 ){
      for (i=1; i<=p; i++){
        sprintf(temp,"%25.16e % 20.8f ",D[i],D[i]);
        cout<<temp<< " D(" << i << ")\n";
      }
    }
    else{
      cout << "Error, status::display, D is not initialized.\n";
    }
 
    break;

  case TERMINATION:
  
    cout << starbox("/theta//_") << theta << "\n";

    if (strcmp(df,"corrected") == 0)
      cout << starbox("/var/(corrected for degrees of freedom)//_");
    else
      cout << starbox("/var/(no degrees of freedom corrections)//_"); 

    cout << var << "\n";

    sprintf(temp,"/V/(rank = %d)//_",rank);
    cout << starbox(temp) << V << "\n";

    break;

  }

  cout.flush();

  return 0;

}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -