Changeset 16571ae in tol
- Timestamp:
- Aug 3, 2012, 9:16:20 AM (14 years ago)
- Branches:
- 1941-docker-image-to-test, devel, master
- Children:
- e3eddff
- Parents:
- 4e555b7b
- Location:
- tol/btol/bmodel
- Files:
-
- 3 edited
-
moddiag.cpp (modified) (15 diffs)
-
model.cpp (modified) (3 diffs)
-
tol_bmodel.h (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
tol/btol/bmodel/moddiag.cpp
r4e555b7b r16571ae 98 98 //-------------------------------------------------------------------- 99 99 { 100 Std(BText("\nTRACE FstRegAutCorTest "));100 //Std(BText("\nTRACE FstRegAutCorTest ")); 101 101 BInt m = 1; 102 102 BDat x,y; … … 114 114 //-------------------------------------------------------------------- 115 115 { 116 Std(BText("\nTRACE FstSeaAutCorTest "));116 //Std(BText("\nTRACE FstSeaAutCorTest ")); 117 117 BInt m = periodicity_; 118 118 BDat x,y; … … 134 134 //-------------------------------------------------------------------- 135 135 { 136 Std(BText("\nTRACE SndRegAutCorTest "));136 //Std(BText("\nTRACE SndRegAutCorTest ")); 137 137 BInt m = 2; 138 138 BDat x,y; … … 150 150 //-------------------------------------------------------------------- 151 151 { 152 Std(BText("\nTRACE SndSeaAutCorTest "));152 //Std(BText("\nTRACE SndSeaAutCorTest ")); 153 153 BInt m = 2*periodicity_; 154 154 BDat x,y; … … 165 165 166 166 //-------------------------------------------------------------------- 167 BInt BModel:: RegBoxPierceLjungTest(BInt n)168 169 /*! Runs the test of the Box-Pierce-Ljung statistic of re gular167 BInt BModel::BoxPierceLjungTest(BInt n) 168 169 /*! Runs the test of the Box-Pierce-Ljung statistic of residuals 170 170 * autocorrelations 171 171 */ 172 172 //-------------------------------------------------------------------- 173 173 { 174 Std(BText("\nTRACE RegBoxPierceLjungTest "));174 //Std(BText("\nTRACE BoxPierceLjungTest ")); 175 175 BInt m = aCorNum_; 176 176 BInt p = arParam_; 177 177 BInt q = maParam_; 178 Std(BText("\nTRACE RegBoxPierceLjungTest N=")+A_.Data().Size()); 179 Std(BText("\nTRACE RegBoxPierceLjungTest m=")+m); 180 Std(BText("\nTRACE RegBoxPierceLjungTest p=")+p); 181 Std(BText("\nTRACE RegBoxPierceLjungTest q=")+q); 182 RegularBoxPierceLjung_ = BoxPierceLjung(A_.Data(), m, p, q); 183 Std(BText("\nTRACE RegBoxPierceLjungTest RegularBoxPierceLjung_=")+RegularBoxPierceLjung_); 178 BoxPierceLjung_ = BoxPierceLjungACF(resACor_.Data(), m, N_); 184 179 BChiSquareDist Chi(m-p-q); 185 diagValue_(n) = RegularBoxPierceLjung_;186 BDat x = Chi.Dist( RegularBoxPierceLjung_);187 Std(BText("\nTRACE RegBoxPierceLjungTest x=")+x);188 //Std(BText("\n Regular Box-Pierce-Ljung = ")+RegularBoxPierceLjung_.Name());180 diagValue_(n) = BoxPierceLjung_; 181 BDat x = Chi.Dist(BoxPierceLjung_); 182 //Std(BText("\nTRACE BoxPierceLjungTest x=")+x); 183 //Std(BText("\nBox-Pierce-Ljung = ")+BoxPierceLjung_.Name()); 189 184 //Std(BText("\nProbability = ")+x.Name()); 190 185 return(Qualify(n,x,BTRUE)); … … 192 187 193 188 //-------------------------------------------------------------------- 194 BInt BModel::SeaBoxPierceLjungTest(BInt n)195 196 /*! Runs the test of the Box-Pierce-Ljung statistic of seasonal197 * autocorrelations198 */199 //--------------------------------------------------------------------200 {201 Std(BText("\nTRACE SeaBoxPierceLjungTest "));202 BBool necessary = (periodicity_ > 1) &&203 (A_.Data().Size()/periodicity_ > 2);204 BDat x;205 if(necessary)206 {207 int j = arFactors_.Size()-1;208 BInt m = aCorNum_/periodicity_;209 BInt p = arFactors_[j].Size()-1;210 BInt q = maFactors_[j].Size()-1;211 BArray<BDat> seaRes(N_/periodicity_);212 for(int i=0; i<seaRes.Size(); i++)213 {214 seaRes[i] = A_.Data()[i*periodicity_];215 // Std(BText("\nseaRes[")+i+"]="+seaRes[i]);216 }217 SeasonalBoxPierceLjung_ = BoxPierceLjung(seaRes, m, p, q);218 diagValue_(n) = SeasonalBoxPierceLjung_;219 BChiSquareDist Chi(m-p-q);220 x = Chi.Dist(SeasonalBoxPierceLjung_);221 /*222 Std(BText("\nSeasonal Box-Pierce-Ljung = ")+223 SeasonalBoxPierceLjung_.Name());224 Std(BText("\nProbability = ")+x.Name());225 */226 }227 return(Qualify(n,x,necessary));228 }229 230 //--------------------------------------------------------------------231 189 BInt BModel::KullbackLeiblerDistanceTest(BInt n) 232 190 … … 235 193 //-------------------------------------------------------------------- 236 194 { 237 Std(BText("\nTRACE KullbackLeiblerDistanceTest "));195 //Std(BText("\nTRACE KullbackLeiblerDistanceTest ")); 238 196 static BReal paso = 0.25; 239 197 static BDat KullbackLeiblerAvr = -5.349629861; … … 286 244 //-------------------------------------------------------------------- 287 245 { 288 Std(BText("\nTRACE FisherDistanceTest "));246 //Std(BText("\nTRACE FisherDistanceTest ")); 289 247 BInt numInterv = BInt(Sqrt(N_)); 290 248 //Std(BText("\nnumInterv=")+numInterv); … … 327 285 //-------------------------------------------------------------------- 328 286 { 329 Std(BText("\nTRACE MinSignificationTest "));287 //Std(BText("\nTRACE MinSignificationTest ")); 330 288 BTStudentDist T(N_-numParam_); 331 289 BInt i; … … 358 316 //-------------------------------------------------------------------- 359 317 { 360 Std(BText("\nTRACE MaxCorrelationTest "));318 //Std(BText("\nTRACE MaxCorrelationTest ")); 361 319 BInt N = paramCor_.Rows(); 362 320 if(!N || !paramCor_.Columns()) … … 384 342 BInt BModel::MixedSignCorrTest(BInt n) 385 343 386 /*! Runs the test of mixed signification and correlation of parameters 387 */ 388 //-------------------------------------------------------------------- 389 { 390 Std(BText("\nTRACE MixedSignCorrTest ")); 344 /*! Runs the test of multicolinearity based on minimum significating 345 * combination of parameters using eigenvector of minimum eigenvalue 346 * of Jacobian. 347 * 348 */ 349 //-------------------------------------------------------------------- 350 { 351 //Std(BText("\nTRACE MixedSignCorrTest ")); 391 352 BTStudentDist T(N_-numParam_); 392 BBool necessary = (diagQualify_[7] != BDIAGREFUSE) && 393 (diagQualify_[8] != BDIAGREFUSE); 394 BDat maxMixed = 0; 395 if(necessary) 396 { 397 if(!paramCor_.Rows() || !paramCor_.Columns()) 398 { 399 diagValue_(n) = BDat::Unknown(); 400 return(Qualify(n,1,BTRUE)); 401 } 402 for(BInt i=0; i<paramCor_.Rows(); i++) 403 { 404 BDat corr=0; 405 for(BInt j=0; j<paramCor_.Rows(); j++) 406 { 407 if(i!=j) 408 { 409 BDat c = Abs(paramCor_(i,j)); 410 if(corr < c) { corr = c; } 411 } 412 } 413 BDat sign = 2*(1-T.Dist(Abs(param_[i]/paramSD_[i]))); 414 BDat mixed = Sqrt(Abs(sign*corr)); 415 if(maxMixed<mixed) { maxMixed = mixed; } 416 } 417 diagValue_(n) = maxMixed; 418 // Std(BText("\nMaximum mixed correlation-signification = ")+ 419 // maxMixed.Name()); 420 } 421 return(Qualify(n,maxMixed,necessary)); 353 BBool necessary = true; 354 if(!numParam_ || (D_.Rows()!=numParam_)||(D_.Columns()!=numParam_)) 355 { 356 diagValue_(n) = BDat::Unknown(); 357 return(Qualify(n,1,BTRUE)); 358 } 359 BDat c = 0; 360 int i; 361 for(i=0;i<numParam_;i++) 362 { 363 c+=param_[i]*V_(i,numParam_-1); 364 } 365 BDat d = D_(numParam_-1,numParam_-1); 366 BDat t = d*c/standardError_; 367 diagValue_(n) = t; 368 BDat refuseProb = 2*(1-T.Dist(Abs(t))); 369 return(Qualify(n,refuseProb,BTRUE)); 422 370 } 423 371 … … 431 379 //-------------------------------------------------------------------- 432 380 { 433 Std(BText("\nTRACE UnitRootsProbTest "));381 //Std(BText("\nTRACE UnitRootsProbTest ")); 434 382 BDat x = 0; 435 383 BInt num = arParam_+maParam_; … … 490 438 { 491 439 for(k=1; k<factors[j].Size(); k++,i++) 492 { factors[j][k].PutCoef(-simula( 0,i)); }440 { factors[j][k].PutCoef(-simula(i,0)); } 493 441 if(!(IsStationary(factors[j]))) { unarys[j]+=1; } 494 442 } … … 523 471 switch(n) 524 472 { 525 case 0 : return(FstRegAutCorTest (n)); 526 case 1 : return(FstSeaAutCorTest (n)); 527 case 2 : return(SndRegAutCorTest (n)); 528 case 3 : return(SndSeaAutCorTest (n)); 529 case 4 : return(RegBoxPierceLjungTest (n)); 530 case 5 : return(SeaBoxPierceLjungTest (n)); 531 case 6 : return(FisherDistanceTest (n)); 532 case 7 : return(MinSignificationTest (n)); 533 case 8 : return(MaxCorrelationTest (n)); 534 case 9 : return(MixedSignCorrTest (n)); 535 case 10 : return(UnitRootsProbTest (n)); 473 case 0 : return(FstRegAutCorTest (n)); 474 case 1 : return(FstSeaAutCorTest (n)); 475 case 2 : return(SndRegAutCorTest (n)); 476 case 3 : return(SndSeaAutCorTest (n)); 477 case 4 : return(BoxPierceLjungTest (n)); 478 case 5 : return(FisherDistanceTest (n)); 479 case 6 : return(MinSignificationTest (n)); 480 case 7 : return(MaxCorrelationTest (n)); 481 case 8 : return(MixedSignCorrTest (n)); 482 case 9 : return(UnitRootsProbTest (n)); 536 483 default : return(-1); 537 484 } … … 568 515 qualification_ = 0; 569 516 arithmeticQualification_ = 0; 570 for(BInt n = 0; n<testTitle_.Size(); n++) 571 { 572 BSet& s = Set(set[n+1]); 517 int n=0, m=1; 518 for(; n<testTitle_.Size(); n++, m++) 519 { 520 BSet& s = Set(set[m]); 521 BText name = set[m]->Name(); 522 if(name=="RegBoxPierceLjungBounds") 523 { 524 name = "PierceLjungBounds"; 525 } 526 else if(name=="SeaBoxPierceLjungBounds") 527 { 528 m++; 529 s = Set(set[m]); 530 name = set[m]->Name(); 531 continue; 532 } 533 if(name!=testName_[n]) 534 { 535 Error(I2("Error in name of","Error en el nombre del")+ 536 " "+(n+1)+"-"+ 537 I2("th element of","ésimo elemento de")+ 538 " Set DiagnosticsBounds "+ 539 I2("that would be","que debería ser")+ 540 " '"+testName_[n]+"' "+ 541 I2("instead of","en lugar de")+ 542 " '"+name+"'." ); 543 } 573 544 diagValue_ (n) = BDat::Unknown(); 574 545 diagPunct_ (n) = 0; -
tol/btol/bmodel/model.cpp
r4e555b7b r16571ae 55 55 56 56 BArray<BText> BModel::qualifTitle_; 57 BArray<BText> BModel::testName_; 57 58 BArray<BText> BModel::testTitle_; 58 59 … … 134 135 BModel::qualifTitle_[3] = I2("REFUSED", "RECHAZADO"); 135 136 136 BModel::testTitle_.ReallocBuffer(11); 137 138 BModel::testName_.ReallocBuffer(10); 139 BModel::testName_[ 0] = "FstRegAutCorBounds"; 140 BModel::testName_[ 1] = "FstSeaAutCorBounds"; 141 BModel::testName_[ 2] = "SndRegAutCorBounds"; 142 BModel::testName_[ 3] = "SndSeaAutCorBounds"; 143 BModel::testName_[ 4] = "BoxPierceLjungBounds"; 144 BModel::testName_[ 5] = "FisherBounds"; 145 BModel::testName_[ 6] = "MinSignificationBounds"; 146 BModel::testName_[ 7] = "MaxCorrelationBounds"; 147 BModel::testName_[ 8] = "MixedSignCorrBounds"; 148 BModel::testName_[ 9] = "UnitRootsProbBounds"; 149 150 151 BModel::testTitle_.ReallocBuffer(10); 137 152 BModel::testTitle_[ 0] = I2("First Regular AutoCorrelation", 138 153 "Primera Autocorrelacion Regular"); … … 143 158 BModel::testTitle_[ 3] = I2("Second Seasonal AutoCorrelation", 144 159 "Segunda Autocorrelación Estacional"); 145 BModel::testTitle_[ 4] = I2("Regular Box-Pierce-Ljung's statistic", 146 "Estadístico de Box-Pierce-Ljung Regular"); 147 BModel::testTitle_[ 5] = I2("Seasonal Box-Pierce-Ljung's statistic", 148 "Estadístico de Box-Pierce-Ljung Estacional"); 149 BModel::testTitle_[ 6] = I2("Fisher's Distance to Normal", 160 BModel::testTitle_[ 4] = I2("Box-Pierce-Ljung's statistic", 161 "Estadístico de Box-Pierce-Ljung"); 162 BModel::testTitle_[ 5] = I2("Fisher's Distance to Normal", 150 163 "Distancia a la normal de Fisher"); 151 BModel::testTitle_[ 7] = I2("Minimum Signification of Parameters",164 BModel::testTitle_[ 6] = I2("Minimum Signification of Parameters", 152 165 "Mínima Significación de los Parámetros"); 153 BModel::testTitle_[ 8] = I2("Maximum Correlation of Parameters",166 BModel::testTitle_[ 7] = I2("Maximum Correlation of Parameters", 154 167 "Máxima Correlación de los Parámetros"); 155 BModel::testTitle_[ 9] = I2("Mixed Signification and Correlation",156 " Combinacion de Significación y Correlación");157 BModel::testTitle_[ 10] = I2("Probabilty of Unary Roots",168 BModel::testTitle_[ 8] = I2("Test of multicolinearity", 169 "Test de multicolinealidad"); 170 BModel::testTitle_[ 9] = I2("Probabilty of Unary Roots", 158 171 "Probabilidad de Raíces Unitarias"); 159 172 isInitialized = BTRUE; -
tol/btol/bmodel/tol_bmodel.h
r4e555b7b r16571ae 70 70 { 71 71 public: //member data 72 static BArray<BText> testName_; 72 73 static BArray<BText> testTitle_; 73 74 static BArray<BText> qualifTitle_; … … 190 191 BDat varianze_; 191 192 BDat SwartzInfo_; 192 BDat RegularBoxPierceLjung_; 193 BDat SeasonalBoxPierceLjung_; 193 BDat BoxPierceLjung_; 194 194 195 195 BDat maxLikelihoodCoef_; … … 296 296 BInt SndRegAutCorTest (BInt n); 297 297 BInt SndSeaAutCorTest (BInt n); 298 BInt RegBoxPierceLjungTest (BInt n); 299 BInt SeaBoxPierceLjungTest (BInt n); 298 BInt BoxPierceLjungTest (BInt n); 300 299 BInt KullbackLeiblerDistanceTest (BInt n); 301 300 BInt FisherDistanceTest (BInt n);
Note: See TracChangeset
for help on using the changeset viewer.
