********  HRAI_MSTATS.TXT -- 28 Dec 2003 - 4 Jan 2004  ********
**

P  -->  PS  -->  PSC  -->  PSCR  -->   PSACR=ANCHOR
            \->  PSA  -->  PSAC  /

Model P:     Perception mechanism only; nearest-anchor responses.
Model PS:    Perception + anchor Selection mechanisms only.
Model PSC:   Perception + Selection + Correction mechanisms only.
Model PSA:   Perception + Selection + Activation, no corrections.
Model PSAC:  All except location learning.
Model PSCR:  All except activation learning.
Model PSACR: Full ANCHOR model.

The general methodology is always the same:
1. Fit the corresponding model to the 24 individual data sets
   from the Absolute Identificaiton Experiment (Expmt 1).
   This produces 24 parameter sets.
   Which parameters are "active", which are shunted off, and
   which are fixed for all subjects depends on the particular model.
2. Run the model with each AI parametrization on each of the
   new AI stimulus sequences, for a total of 9600=24*400 runs.
3. Calculate a battery of model statistics via AI_STATS and
   compare them with the empirical ones.

This file carries out steps 2. and 3. above.
See HRAI_PSEARCH.TXT for details on the parameter search (step 1.)
The results from each parameter search are stored in HIER_OPT_PARAMS.MAT.
The summary statistics for each model are stored in HIER_SUMSTATS.MAT.
See also HRCR_PSEARCH.TXT AND HRCR_MSTATS.TXT for category-rating analogs.

WARNING: The sign of the context measure d is reversed in the manuscript.


*************************************************************
***                ******************************************
***   Stimuli      ******************************************
***                ******************************************
*************************************************************

%%%%%  Generate 9600=24*400 absolute identification sequences.
%%     Each 'pseudosubject' gets the same 400 sequences,
%%     repeated for each model on the hierarchy.
%%     200 sequences according to Schedule 1 and 200 to Schedule 2.
%%     These are codes '201' and '202' in GENERATE_STIMULI.M.

 clear all ; cd 'C:\work\anchor\finalsim\' ;
 AIstim1=reshape(generate_stimuli(struct('N_runs',24*200,'schedule',201)),[450,200,24]);
 AIstim2=reshape(generate_stimuli(struct('N_runs',24*200,'schedule',202)),[450,200,24]);

 xtab1(AIstim1([1:90]+90,200,24))
   Value   Count  Percent  Cum_cnt  Cum_pct
-------------------------------------------
     275       2     2.22        2     2.22
     325       4     4.44        6     6.67
     375       6     6.67       12    13.33
     425       8     8.89       20    22.22
     475      10    11.11       30    33.33
     525      12    13.33       42    46.67
     575      14    15.56       56    62.22
     625      16    17.78       72    80.00
     675      18    20.00       90   100.00
-------------------------------------------

 xtab1(AIstim1([1:90]+270,200,24))
   Value   Count  Percent  Cum_cnt  Cum_pct
-------------------------------------------
     275      18    20.00       18    20.00
     325      16    17.78       34    37.78
     375      14    15.56       48    53.33
     425      12    13.33       60    66.67
     475      10    11.11       70    77.78
     525       8     8.89       78    86.67
     575       6     6.67       84    93.33
     625       4     4.44       88    97.78
     675       2     2.22       90   100.00
-------------------------------------------

 xtab1(AIstim2([1:90]+90,200,24))
   Value   Count  Percent  Cum_cnt  Cum_pct
-------------------------------------------
     275      18    20.00       18    20.00
     325      16    17.78       34    37.78
     375      14    15.56       48    53.33
     425      12    13.33       60    66.67
     475      10    11.11       70    77.78
     525       8     8.89       78    86.67
     575       6     6.67       84    93.33
     625       4     4.44       88    97.78
     675       2     2.22       90   100.00
-------------------------------------------

 xtab1(AIstim2([1:90]+270,200,24))
   Value   Count  Percent  Cum_cnt  Cum_pct
-------------------------------------------
     275       2     2.22        2     2.22
     325       4     4.44        6     6.67
     375       6     6.67       12    13.33
     425       8     8.89       20    22.22
     475      10    11.11       30    33.33
     525      12    13.33       42    46.67
     575      14    15.56       56    62.22
     625      16    17.78       72    80.00
     675      18    20.00       90   100.00
-------------------------------------------

 whos
  Name          Size         Bytes  Class
-------------------------------------------------
  AIstim1     450x200x24  17280000  double array
  AIstim2     450x200x24  17280000  double array
  CRstim1     450x120x40  17280000  double array
  CRstim2     450x120x40  17280000  double array
-------------------------------------------------
Grand total is 8640000 elements using 69120000 bytes


*************************************************************
***                ******************************************
***   Model P      ******************************************
***   Abs. Ident   ******************************************
***                ******************************************
*************************************************************
28 Dec 2003

Active parameters:  perc_k
Shunted parameters: mem_k=0, temper=0, hist=0, cutoff=Inf, alpha=0
Fixed parameters:   perc_k=0.04, decay=0.5, L1=0.275, L9=0.675, avail=[1:9]'

 cd 'C:\work\anchor\finalsim\' ; load hier_stimuli ;
 load hier_opt_params ;      % resAI24_P, among others

%% Optimal AI params
 resAI=resAI24_P ; v2p=resAI.search_params.v2p_templ;v2p'
ans = 'PARAMS.perc_k = VAL / 10 ;'

 p0=resAI.search_params.params;x=resAI.opt_X;describe(x)
    Mean  Std.dev       Min     Q25  Median     Q75     Max
------------------------------------------------------------
   0.747    0.113      0.53    0.69    0.74    0.82    0.98  % perc_k * 10

% Due to an unfortunate programming shortcut, ANCHOR2.M multiplies
% all anchor magnitudes by 0.0 when mem_k=0. Setting it to 1e-10
% achieves the desired effect.
% Letting T=0 does not cause division by zero -- see SOFTMAX1.M.

 p0.mem_k=1e-10 ;
 for k=1:24 AI_params(k)=vector2params(x(k,:),p0,v2p);end;AI_params(24)
AI_params(24) =
       scale: 'LINEAR'
       N_cat: 9
     SM_conv: 0.0010
      cat_sz: 0.0500
      perc_k: 0.0685
       mem_k: 1.0000e-010
       avail: [9x1 double]
     anchors: [9x6 double]
     cutoffs: [-Inf -Inf Inf Inf]
      temper: 0
     history: 0
       alpha: 0
       decay: 0.5000
         ITI: 4
    M_raster: 7
    A_raster: [5 5 3 3]
    mnfieldp: 1

 AI_params(24).anchors(:,1)'
ans = [0.2750 0.3250 0.3750 0.4250 0.4750 0.5250 0.5750 0.6250 0.6750]

%% Run the model
 AIfdbk1=(AIstim1-225)./50 ; AIfdbk2=(AIstim2-225)./50 ;
 AImresp1=zeros(size(AIstim1));AImresp2=zeros(size(AIstim2));
 tic; for k=1:24;fprintf('%d ',k);p=AI_params(k);
    AImresp1(:,:,k)=anchor2(AIstim1(:,:,k),p,AIfdbk1(:,:,k));
    AImresp2(:,:,k)=anchor2(AIstim2(:,:,k),p,AIfdbk2(:,:,k)); end;toc

% Elapsed_time = 811.0960 sec (14 min) on a Dell Optiplex GX400.

%% Calculate statistics
 s=[reshape(AIfdbk1,450,200*24),reshape(AIfdbk2,450,200*24)];
 mr=[reshape(AImresp1,450,200*24),reshape(AImresp2,450,200*24)];
 tic;st=AI_stats(s,mr);toc

% Elapsed_time = 1.6022e+003 sec (27 min) on a Dell Optiplex GX400.

 sstAI24_P=AI_summary(st)
sstAI24_P =
    resp_mean: [5.0300 0.1180 4.9626 0.0344 4.8200 4.9644 5.1022]
     resp_std: [2.4040 0.0870 2.5905 0.0283 2.4809 2.5904 2.7259]
           R2: [0.9010 0.0350 0.9227 0.0196 0.8501 0.9237 0.9682]
            T: [1.6850 0.2070 1.7905 0.1641 1.3846 1.7768 2.3177]
          bow: [0.1420 0.4030 -0.4204 0.3092 -1.6094 -0.4234 0.8821]
           pr: [0.0650 0.1230 -0.0010 0.0706 -0.2556 0 0.2556]
       deltaS: [0.0220 0.1580 0.0026 0.0872 -0.3188 0.0023 0.3407]
     deltaARL: [0.0200 0.2220 -0.0019 0.1076 -0.4663 -0.0027 0.4035]
          rep: [0.1150 0.0860 0.0097 0.0734 -0.3037 0.0105 0.2762]
         rrep: [0.6460 0.0900 0.6044 0.0892 0.2667 0.6034 0.9286]
         nrep: [0.5310 0.0840 0.5947 0.0632 0.4272 0.5885 0.7889]
WARNING: The sign of the context measure d is reversed in the manuscript.  WARNING
            d: [-0.1450 0.2440 0.0022 0.1875 -0.7142 0.0014 0.7326]
           d1: [-0.2330 0.2150 0.0049 0.1875 -0.6604 0.0054 0.7238]
           d2: [-0.0570 0.2490 -4.4e-4 0.1875 -0.7142 -0.0015 0.7326]
     mn_scale: [1.111 2.002 3.001 4.000 4.999 5.999 6.998 7.938 8.616]
     mn_stdev: [0.300 0.537 0.617 0.686 0.757 0.825 0.887 0.864 0.621]
     mn_Pcorr: [0.889 0.701 0.633 0.575 0.525 0.483 0.447 0.414 0.694]
    mn_dprime: [2.3715 2.0171 1.7562 1.5544 1.4006 1.2748 1.1626 1.0761]
    mn_blkacc: [0.5959 0.5964 0.5963 0.5955 0.5949]
    mn_blkstd: [2.5904 2.2471 2.5883 2.2482 2.5878]
       mn_ARL: [4.966 4.967 4.983 4.979 4.965 4.962 4.981 4.984 4.965 4.962;
                4.966 4.969 4.979 4.981 4.964 4.968 4.982 4.982 4.966 4.968]

 fprintf('%.3f ',sstAI24_P.mn_scale)
 fprintf('%.3f ',sstAI24_P.mn_stdev)
 fprintf('%.3f ',sstAI24_P.mn_Pcorr)
 a=sstAI24_P.mn_ARL;fprintf('%.3f ',a(1,:));fprintf('\n');fprintf('%.3f ',a(2,:));
 save sstAI24_P sstAI24_P


*************************************************************
***                ******************************************
***   Model PS     ******************************************
***   Abs. Ident   ******************************************
***                ******************************************
*************************************************************
28 Dec 2003

Active parameters:  mem_k, temper
Shunted parameters: hist=0, cutoff=Inf, alpha=0
Fixed parameters:   perc_k=0.04, decay=0.5,
                    L1=0.275, L9=0.675, avail=[1:9]'

 cd 'C:\work\anchor\finalsim\' ; load hier_stimuli ;
 load hier_opt_params ;      % resAI24_PS, among others

%% Optimal AI params
 resAI=resAI24_PS ; v2p=resAI.search_params.v2p_templ;v2p'
ans = 'PARAMS.mem_k = VAL / 10 ;'
      'PARAMS.temper = VAL / 10 ;'

 p0=resAI.search_params.params;x=resAI.opt_X;describe(x)
    Mean  Std.dev       Min     Q25  Median     Q75     Max
------------------------------------------------------------
   0.672    0.220      0.20    0.52    0.66    0.83    1.02  % mem_k * 10
   0.174    0.085      0.10    0.10    0.11    0.27    0.32  % temper* 10

 for k=1:24 AI_params(k)=vector2params(x(k,:),p0,v2p);end;AI_params(24)
AI_params(24) =
       scale: 'LINEAR'
       N_cat: 9
     SM_conv: 0.0010
      cat_sz: 0.0500
      perc_k: 0.0400
       mem_k: 0.0723
       avail: [9x1 double]
     anchors: [9x6 double]
     cutoffs: [-Inf -Inf Inf Inf]
      temper: 0.0100
     history: 0
       alpha: 0
       decay: 0.5000
         ITI: 4
    M_raster: 7
    A_raster: [5 5 3 3]
    mnfieldp: 1

 AI_params(24).anchors(:,1)'
ans = [0.2750 0.3250 0.3750 0.4250 0.4750 0.5250 0.5750 0.6250 0.6750]

%% Run the model
 AIfdbk1=(AIstim1-225)./50 ; AIfdbk2=(AIstim2-225)./50 ;
 AImresp1=zeros(size(AIstim1));AImresp2=zeros(size(AIstim2));
 tic; for k=1:24;fprintf('%d ',k);p=AI_params(k);
    AImresp1(:,:,k)=anchor2(AIstim1(:,:,k),p,AIfdbk1(:,:,k));
    AImresp2(:,:,k)=anchor2(AIstim2(:,:,k),p,AIfdbk2(:,:,k)); end;toc

% Elapsed_time = 902.0270 sec (15 min) on a Dell Optiplex GX400.

%% Calculate statistics
 s=[reshape(AIfdbk1,450,200*24),reshape(AIfdbk2,450,200*24)];
 mr=[reshape(AImresp1,450,200*24),reshape(AImresp2,450,200*24)];
 tic;stAI_PS=AI_stats(s,mr);toc

% Elapsed_time = 135.7460 sec (3 min) on a Dell Optiplex GX400.

 sstAI24_PS=AI_summary(stAI_PS)
sstAI24_PS =
    resp_mean: [5.0300 0.1180 4.9904 0.0415 4.8067 4.9889 5.1578]
     resp_std: [2.4040 0.0870 2.5545 0.0353 2.3834 2.5564 2.6823]
           R2: [0.9010 0.0350 0.8810 0.0381 0.7529 0.8798 0.9647]
            T: [1.6850 0.2070 1.5320 0.2271 1.0122 1.4913 2.2386]
          bow: [0.1420 0.4030 -0.4711 0.3016 -1.5852 -0.4751 1.0779]
           pr: [0.0650 0.1230 5.1042e-4 0.0720 -0.2889 0 0.2667]
       deltaS: [0.0220 0.1580 4.0941e-4 0.1029 -0.3933 6.6613e-16 0.3774]
     deltaARL: [0.0200 0.2220 0.0016 0.1314 -0.5508 0.0029 0.5236]
          rep: [0.1150 0.0860 0.0069 0.0748 -0.2555 0.0067 0.3617]
         rrep: [0.6460 0.0900 0.5241 0.1040 0.2222 0.5172 0.9024]
         nrep: [0.5310 0.0840 0.5171 0.0808 0.3325 0.5037 0.7792]
WARNING: The sign of the context measure d is reversed in the manuscript.  WARNING
            d: [-0.1450 0.2440 -0.0004 0.2256 -0.9343 -0.0009 0.8929]
           d1: [-0.2330 0.2150 -0.0028 0.2260 -0.9343 -0.0029 0.8400]
           d2: [-0.0570 0.2490  0.0021 0.2252 -0.8727  0.0020 0.8929]
     mn_scale: [1.270 2.092 3.068 4.068 5.075 6.069 7.020 7.841 8.411]
     mn_stdev: [0.503 0.709 0.810 0.889 0.952 0.995 0.991 0.900 0.723]
     mn_Pcorr: [0.770 0.600 0.540 0.495 0.459 0.427 0.405 0.413 0.551]
    mn_dprime: [1.7523 1.6146 1.4496 1.3179 1.2057 1.1018 0.9816 0.7977]
    mn_blkacc: [0.5179 0.5173 0.5173 0.5186 0.5184]
    mn_blkstd: [2.5524 2.2330 2.5523 2.2306 2.5520]
       mn_ARL: [4.985 4.986 5.013 5.016 4.986 4.986 5.013 5.013 4.988 4.986;
                4.986 4.985 5.013 5.018 4.987 4.989 5.016 5.016 4.989 4.986]

 fprintf('%.3f ',sstAI24_PS.mn_scale)
 fprintf('%.3f ',sstAI24_PS.mn_stdev)
 fprintf('%.3f ',sstAI24_PS.mn_Pcorr)
 a=sstAI24_PS.mn_ARL;fprintf('%.3f ',a(1,:));fprintf('\n');fprintf('%.3f ',a(2,:));
 save sstAI24_PS sstAI24_PS


*************************************************************
***                ******************************************
***   Model PSC    ******************************************
***   Abs. Ident   ******************************************
***                ******************************************
*************************************************************
29 Dec 2003

Active parameters:  mem_k, temper, cutoff
Shunted parameters: hist=0, alpha=0
Fixed parameters:   perc_k=0.04, decay=0.5,
                    L1=0.275, L9=0.675, avail=[1:9]'
                    cutoff multipliers=[-3 -1 +0.9 +2.7]

 cd 'C:\work\anchor\finalsim\' ; load hier_stimuli ;
 load hier_opt_params ;      % resAI24_PSC, among others

%% Optimal AI params
 resAI=resAI24_PSC ; v2p=resAI.search_params.v2p_templ;v2p'
ans = 'PARAMS.mem_k = VAL / 10 ;'
      'PARAMS.temper = VAL / 10 ;'
      'PARAMS.cutoffs = VAL*[-3 -1 +0.9 +2.7] ;'

 p0=resAI.search_params.params;x=resAI.opt_X;describe(x)
    Mean  Std.dev       Min     Q25  Median     Q75     Max
------------------------------------------------------------
   0.588    0.315      0.20    0.27    0.58    0.89    1.00  % mem_k * 10
   0.376    0.195      0.20    0.20    0.25    0.56    0.76  % temper* 10
   0.898    0.232      0.50    0.72    0.86    1.07    1.50  % cutoff

 for k=1:24 AI_params(k)=vector2params(x(k,:),p0,v2p);end;AI_params(24)
AI_params(24) =
       scale: 'LINEAR'
       N_cat: 9
     SM_conv: 0.0010
      cat_sz: 0.0500
      perc_k: 0.0400
       mem_k: 0.0758
       avail: [9x1 double]
     anchors: [9x6 double]
     cutoffs: [-2.1664 -0.7221 0.6499 1.9498]
      temper: 0.0200
     history: 0
       alpha: 0
       decay: 0.5000
         ITI: 4
    M_raster: 7
    A_raster: [5 5 3 3]
    mnfieldp: 1

 AI_params(24).anchors(:,1)'
ans = [0.2750 0.3250 0.3750 0.4250 0.4750 0.5250 0.5750 0.6250 0.6750]

%% Run the model
 AIfdbk1=(AIstim1-225)./50 ; AIfdbk2=(AIstim2-225)./50 ;
 AImresp1=zeros(size(AIstim1));AImresp2=zeros(size(AIstim2));
 tic; for k=1:24;fprintf('%d ',k);p=AI_params(k);
    AImresp1(:,:,k)=anchor2(AIstim1(:,:,k),p,AIfdbk1(:,:,k));
    AImresp2(:,:,k)=anchor2(AIstim2(:,:,k),p,AIfdbk2(:,:,k)); end;toc

% Elapsed_time = 914.9260 sec (16 min) on a Dell Optiplex GX400.

%% Calculate statistics
 s=[reshape(AIfdbk1,450,200*24),reshape(AIfdbk2,450,200*24)];
 mr=[reshape(AImresp1,450,200*24),reshape(AImresp2,450,200*24)];
 tic;stAI_PSC=AI_stats(s,mr);toc

% Elapsed_time = 131.7390 sec (3 min) on a Dell Optiplex GX400.

 sstAI24_PSC=AI_summary(stAI_PSC)
sstAI24_PSC =
    resp_mean: [5.0300 0.1180 5.0253 0.0408 4.8422 5.0244 5.2689]
     resp_std: [2.4040 0.0870 2.5162 0.0547 2.2908 2.5238 2.6655]
           R2: [0.9010 0.0350 0.8867 0.0373 0.7397 0.8865 0.9582]
            T: [1.6850 0.2070 1.5671 0.2155 1.0409 1.5291 2.1367]
          bow: [0.1420 0.4030 -0.3021 0.3422 -1.6544 -0.3084 1.1176]
           pr: [0.0650 0.1230 0.0011 0.0717 -0.3000 0 0.3000]
       deltaS: [0.0220 0.1580 -0.0010 0.1004 -0.4152 -0.0006 0.3708]
     deltaARL: [0.0200 0.2220 9.4406e-004 0.1244 -0.5235 2.1253e-004 0.5294]
          rep: [0.1150 0.0860 0.0066 0.0755 -0.2739 0.0069 0.2747]
         rrep: [0.6460 0.0900 0.5295 0.1013 0.2000 0.5263 0.8800]
         nrep: [0.5310 0.0840 0.5230 0.0772 0.3250 0.5111 0.7363]
WARNING: The sign of the context measure d is reversed in the manuscript.  WARNING
            d: [-0.1450 0.2440 -0.0024 0.2164 -1.1724 -0.0011 0.8617]
           d1: [-0.2330 0.2150 -0.0044 0.2167 -1.1724 -0.0011 0.8607]
           d2: [-0.0570 0.2490 -4.3027e-004 0.2162 -0.9150 -0.0012 0.8617]
     mn_scale: [1.350 2.184 3.135 4.111 5.098 6.065 6.993 7.828 8.464]
     mn_stdev: [0.567 0.712 0.783 0.846 0.897 0.931 0.926 0.868 0.698]
     mn_Pcorr: [0.710 0.607 0.540 0.497 0.463 0.440 0.428 0.446 0.581]
    mn_dprime: [1.7586 1.5747 1.4239 1.3168 1.2114 1.1294 1.0494 0.9683]
    mn_blkacc: [0.5233 0.5236 0.5238 0.5234 0.5244]
    mn_blkstd: [2.5137 2.1973 2.5140 2.1948 2.5147]
       mn_ARL: [5.022 5.022 5.043 5.044 5.019 5.020 5.048 5.039 5.021 5.021;
                5.019 5.021 5.043 5.045 5.022 5.024 5.048 5.045 5.023 5.022]

 fprintf('%.3f ',sstAI24_PSC.mn_scale)
 fprintf('%.3f ',sstAI24_PSC.mn_stdev)
 fprintf('%.3f ',sstAI24_PSC.mn_Pcorr)
 a=sstAI24_PSC.mn_ARL;fprintf('%.3f ',a(1,:));fprintf('\n');fprintf('%.3f ',a(2,:));
 save sstAI24_PSC sstAI24_PSC


*************************************************************
***                ******************************************
***   Model PSA    ******************************************
***   Abs. Ident   ******************************************
***                ******************************************
*************************************************************
4 Jan 2004

Active parameters:  mem_k, temper, hist
Shunted parameters: cutoff=Inf, alpha=0
                    L1=0.275, L9=0.675, avail=[1:9]'
                    cutoff multipliers=[-3 -1 +0.9 +2.7]

 cd 'C:\work\anchor\finalsim\' ; load hier_stimuli ;
 load hier_opt_params ;      % resAI24_PSA, among others

%% Optimal AI params
 resAI=resAI24_PSA ; v2p=resAI.search_params.v2p_templ;v2p'
ans = 'PARAMS.mem_k = VAL / 10 ;'
      'PARAMS.temper = VAL / 10 ;'
      'PARAMS.history = VAL / 5 ;'

 p0=resAI.search_params.params;x=resAI.opt_X;describe(x)
    Mean  Std.dev       Min     Q25  Median     Q75     Max
------------------------------------------------------------
   0.425    0.235      0.20    0.21    0.39    0.58    1.00  % mem_k * 10
   0.255    0.051      0.20    0.20    0.25    0.31    0.33  % temper* 10
   0.250    0.000      0.25    0.25    0.25    0.25    0.25  % history* 5

 for k=1:24 AI_params(k)=vector2params(x(k,:),p0,v2p);end;AI_params(24)
AI_params(24) =
       scale: 'LINEAR'
       N_cat: 9
     SM_conv: 0.0010
      cat_sz: 0.0500
      perc_k: 0.0400
       mem_k: 0.0457
       avail: [9x1 double]
     anchors: [9x6 double]
     cutoffs: [-Inf -Inf Inf Inf]
      temper: 0.0200
     history: 0.0500
       alpha: 0
       decay: 0.5000
         ITI: 4
    M_raster: 7
    A_raster: [5 5 3 3]
    mnfieldp: 1

 AI_params(24).anchors(:,1)'
ans = [0.2750 0.3250 0.3750 0.4250 0.4750 0.5250 0.5750 0.6250 0.6750]

%% Run the model
 AIfdbk1=(AIstim1-225)./50 ; AIfdbk2=(AIstim2-225)./50 ;
 AImresp1=zeros(size(AIstim1));AImresp2=zeros(size(AIstim2));
 tic; for k=1:24;fprintf('%d ',k);p=AI_params(k);
    AImresp1(:,:,k)=anchor2(AIstim1(:,:,k),p,AIfdbk1(:,:,k));
    AImresp2(:,:,k)=anchor2(AIstim2(:,:,k),p,AIfdbk2(:,:,k)); end;toc

% Elapsed_time =  857.9240 sec (15 min) on a Dell Optiplex GX400.

%% Calculate statistics
 s=[reshape(AIfdbk1,450,200*24),reshape(AIfdbk2,450,200*24)];
 mr=[reshape(AImresp1,450,200*24),reshape(AImresp2,450,200*24)];
 tic;stAI_PSA=AI_stats(s,mr);toc

% Elapsed_time = 128.2940 sec (2 min) on a Dell Optiplex GX400.

 sstAI24_PSA=AI_summary(stAI_PSA)
sstAI24_PSA =
    resp_mean: [5.0300 0.1180 4.9881 0.0552 4.7622 4.9867 5.2222]
     resp_std: [2.4040 0.0870 2.5522 0.0368 2.3902 2.5534 2.6839]
           R2: [0.9010 0.0350 0.8774 0.0366 0.7379 0.8797 0.9451]
            T: [1.6850 0.2070 1.4964 0.1860 0.9665 1.4833 1.9686]
          bow: [0.1420 0.4030 -0.3841 0.2959 -1.4784 -0.3940 0.7471]
           pr: [0.0650 0.1230 0.0550 0.0721 -0.2222 0.0556 0.3222]
       deltaS: [0.0220 0.1580 -0.0105 0.1131 -0.4016 -0.0117 0.4383]
     deltaARL: [0.0200 0.2220 -0.0011 0.1385 -0.5939 -0.0025 0.5369]
          rep: [0.1150 0.0860 0.1481 0.0725 -0.1183 0.1501 0.4303]
         rrep: [0.6460 0.0900 0.6448 0.0999 0.2889 0.6462 0.9231]
         nrep: [0.5310 0.0840 0.4966 0.0686 0.2988 0.4950 0.6801]
WARNING: The sign of the context measure d is reversed in the manuscript.  WARNING
            d: [-0.1450 0.2440 -0.1427 0.2271 -1.2173 -0.1346 0.6459]
           d1: [-0.2330 0.2150 -0.1428 0.2265 -1.1834 -0.1323 0.6150]
           d2: [-0.0570 0.2490 -0.1427 0.2277 -1.2173 -0.1381 0.6459]
     mn_scale: [1.341 2.108 3.051 4.038 5.036 6.025 6.988 7.851 8.455]
     mn_stdev: [0.587 0.765 0.864 0.924 0.961 0.986 0.975 0.896 0.709]
     mn_Pcorr: [0.723 0.563 0.517 0.487 0.463 0.439 0.421 0.427 0.580]
    mn_dprime: [1.5034 1.4724 1.3844 1.3044 1.2258 1.1498 1.0573 0.8820]
    mn_blkacc: [0.4739 0.5198 0.5187 0.5259 0.5289]
    mn_blkstd: [2.5431 2.2016 2.5413 2.2255 2.5537]
       mn_ARL: [4.986 4.987 5.076 5.132 5.076 5.058 5.024 4.989 4.985 4.985;
                4.991 4.986 4.927 4.876 4.893 4.917 4.980 5.018 4.990 4.986]

 fprintf('%.3f ',sstAI24_PSA.mn_scale)
 fprintf('%.3f ',sstAI24_PSA.mn_stdev)
 fprintf('%.3f ',sstAI24_PSA.mn_Pcorr)
 a=sstAI24_PSA.mn_ARL;fprintf('%.3f ',a(1,:));fprintf('\n');fprintf('%.3f ',a(2,:));
 save sstAI24_PSA sstAI24_PSA


*************************************************************
***                ******************************************
***   Model PSAC   ******************************************
***   Abs. Ident   ******************************************
***                ******************************************
*************************************************************
4 Jan 2004

Active parameters:  mem_k, temper, hist, cutoff
Shunted parameters: alpha=0
Fixed parameters:   perc_k=0.04, decay=0.5,
                    L1=0.275, L9=0.675, avail=[1:9]'
                    cutoff multipliers=[-3 -1 +0.9 +2.7]

 cd 'C:\work\anchor\finalsim\' ; load hier_stimuli ;
 load hier_opt_params ;      % resAI24_PSAC, among others

%% Optimal AI params
 resAI=resAI24_PSAC ; v2p=resAI.search_params.v2p_templ;v2p'
ans = 'PARAMS.mem_k = VAL / 10 ;'
      'PARAMS.temper = VAL / 10 ;'
      'PARAMS.history = VAL / 5 ;'
      'PARAMS.cutoffs = VAL*[-3 -1 +0.9 +2.7] ;'

% Convert the CORRECTED parameters. See the post-optimization
% correction for Models PSAC and PSACR in HRAI_PSEARCH.TXT.
 p0=resAI.search_params.params;x=resAI.corr_X;describe(x)
    Mean  Std.dev       Min     Q25  Median     Q75     Max
------------------------------------------------------------
   0.483    0.216      0.30    0.30    0.39    0.64    0.89  % mem_k * 10
   0.492    0.091      0.40    0.40    0.47    0.60    0.60  % temper* 10
   0.386    0.237      0.25    0.25    0.25    0.44    0.97  % history* 5
   0.758    0.191      0.50    0.60    0.73    0.92    1.04  % cutoff

 for k=1:24 AI_params(k)=vector2params(x(k,:),p0,v2p);end;AI_params(24)
AI_params(24) =
       scale: 'LINEAR'
       N_cat: 9
     SM_conv: 0.0010
      cat_sz: 0.0500
      perc_k: 0.0400
       mem_k: 0.0573
       avail: [9x1 double]
     anchors: [9x6 double]
     cutoffs: [-1.9181 -0.6394 0.5754 1.7263]
      temper: 0.0400
     history: 0.0500
       alpha: 0
       decay: 0.5000
         ITI: 4
    M_raster: 7
    A_raster: [5 5 3 3]
    mnfieldp: 1

 AI_params(24).anchors(:,1)'
ans = [0.2750 0.3250 0.3750 0.4250 0.4750 0.5250 0.5750 0.6250 0.6750]

%% Run the model
 AIfdbk1=(AIstim1-225)./50 ; AIfdbk2=(AIstim2-225)./50 ;
 AImresp1=zeros(size(AIstim1));AImresp2=zeros(size(AIstim2));
 tic; for k=1:24;fprintf('%d ',k);p=AI_params(k);
    AImresp1(:,:,k)=anchor2(AIstim1(:,:,k),p,AIfdbk1(:,:,k));
    AImresp2(:,:,k)=anchor2(AIstim2(:,:,k),p,AIfdbk2(:,:,k)); end;toc

% Elapsed_time =  875.0180 (15 min) on a Dell Optiplex GX400.

%% Calculate statistics
 s=[reshape(AIfdbk1,450,200*24),reshape(AIfdbk2,450,200*24)];
 mr=[reshape(AImresp1,450,200*24),reshape(AImresp2,450,200*24)];
 tic;stAI_PSAC=AI_stats(s,mr);toc

% Elapsed_time = 129.3660 sec (2 min) on a Dell Optiplex GX400.

 sstAI24_PSAC=AI_summary(stAI_PSAC)
sstAI24_PSAC =
    resp_mean: [5.0300 0.1180 5.0254 0.0508 4.8378 5.0222 5.2778]
     resp_std: [2.4040 0.0870 2.5025 0.0448 2.3190 2.5047 2.6439]
           R2: [0.9010 0.0350 0.8997 0.0329 0.7796 0.9009 0.9647]
            T: [1.6850 0.2070 1.6603 0.2144 1.1056 1.6332 2.2554]
          bow: [0.1420 0.4030 -0.2938 0.3317 -1.5110 -0.2983 0.9740]
           pr: [0.0650 0.1230 0.0138 0.0710 -0.2556 0.0111 0.2667]
       deltaS: [0.0220 0.1580 -0.0130 0.0980 -0.4533 -0.0112 0.3800]
     deltaARL: [0.0200 0.2220 -6.9255e-4 0.1178 -0.4860 -0.0017 0.4606]
          rep: [0.1150 0.0860 0.0476 0.0757 -0.2276 0.0477 0.3333]
         rrep: [0.6460 0.0900 0.6042 0.0984 0.2830 0.6000 0.9286]
         nrep: [0.5310 0.0840 0.5566 0.0801 0.3602 0.5466 0.7650]
WARNING: The sign of the context measure d is reversed in the manuscript.  WARNING
            d: [-0.1450 0.2440 -0.1141 0.2148 -1.3427 -0.1041 0.7436]
           d1: [-0.2330 0.2150 -0.1170 0.2187 -1.3427 -0.1064 0.7436]
           d2: [-0.0570 0.2490 -0.1113 0.2108 -1.0766 -0.1019 0.6672]
     mn_scale: [1.340 2.206 3.146 4.107 5.076 6.035 6.969 7.839 8.512]
     mn_stdev: [0.585 0.672 0.724 0.773 0.817 0.852 0.862 0.835 0.682]
     mn_Pcorr: [0.722 0.655 0.592 0.541 0.505 0.480 0.471 0.478 0.613]
    mn_dprime: [2.0044 1.7648 1.5725 1.4502 1.3333 1.2509 1.1780 1.1080]
    mn_blkacc: [0.5523 0.5677 0.5607 0.5631 0.5661]
    mn_blkstd: [2.4926 2.1546 2.4933 2.1777 2.5056]
       mn_ARL: [5.024 5.024 5.098 5.145 5.095 5.079 5.062 5.028 5.020 5.024;
                5.023 5.026 4.980 4.942 4.950 4.966 5.024 5.053 5.026 5.024]

 fprintf('%.3f ',sstAI24_PSAC.mn_scale)
 fprintf('%.3f ',sstAI24_PSAC.mn_stdev)
 fprintf('%.3f ',sstAI24_PSAC.mn_Pcorr)
 a=sstAI24_PSAC.mn_ARL;fprintf('%.3f ',a(1,:));fprintf('\n');fprintf('%.3f ',a(2,:));
 save sstAI24_PSAC sstAI24_PSAC


*************************************************************
***                ******************************************
***   Model PSCR   ******************************************
***   Abs. Ident   ******************************************
***                ******************************************
*************************************************************
4 Jan 2004

Active parameters:  mem_k, temper, cutoff
Shunted parameters: hist=0
Fixed parameters:   perc_k=0.04, alpha=0.3, decay=0.5,
                    L1=0.275, L9=0.675, avail=[1 ; 9] only
                    cutoff multipliers=[-3 -1 +0.9 +2.7]

 cd 'C:\work\anchor\finalsim\' ; load hier_stimuli ;
 load hier_opt_params ;      % resAI24_PSCR, among others

%% Optimal AI params
 resAI=resAI24_PSCR ; v2p=resAI.search_params.v2p_templ;v2p'
ans = 'PARAMS.mem_k = VAL / 10 ;'
      'PARAMS.temper = VAL / 10 ;'
      'PARAMS.cutoffs = VAL*[-3 -1 +0.9 +2.7] ;'

% Convert the CORRECTED parameters. See the post-optimization
% correction for Models PSCR and PSACR in HRAI_PSEARCH.TXT.
 p0=resAI.search_params.params;x=resAI.corr_X;describe(x)
    Mean  Std.dev       Min     Q25  Median     Q75     Max
------------------------------------------------------------
   0.515    0.238      0.30    0.30    0.40    0.78    0.89  % mem_k * 10
   0.533    0.080      0.40    0.47    0.58    0.60    0.60  % temper* 10
   0.798    0.200      0.50    0.60    0.80    1.01    1.04  % cutoff

 for k=1:24 AI_params(k)=vector2params(x(k,:),p0,v2p);end;AI_params(24)
AI_params(24) =
       scale: 'LINEAR'
       N_cat: 9
     SM_conv: 0.0010
      cat_sz: 0.0500
      perc_k: 0.0400
       mem_k: 0.0718
       avail: [2x1 double]
     anchors: [9x6 double]
     cutoffs: [-1.7726 -0.5909 0.5318 1.5953]
      temper: 0.0600
     history: 0
       alpha: 0.3000
       decay: 0.5000
         ITI: 4
    M_raster: 7
    A_raster: [5 5 3 3]
    mnfieldp: 1

 AI_params(24).anchors(:,1)'
ans = [0.2750 0.3250 0.3750 0.4250 0.4750 0.5250 0.5750 0.6250 0.6750]

%% Run the model
 AIfdbk1=(AIstim1-225)./50 ; AIfdbk2=(AIstim2-225)./50 ;
 AImresp1=zeros(size(AIstim1));AImresp2=zeros(size(AIstim2));
 tic; for k=1:24;fprintf('%d ',k);p=AI_params(k);
    AImresp1(:,:,k)=anchor2(AIstim1(:,:,k),p,AIfdbk1(:,:,k));
    AImresp2(:,:,k)=anchor2(AIstim2(:,:,k),p,AIfdbk2(:,:,k)); end;toc

% Elapsed_time =  883.5810 (15 min) on a Dell Optiplex GX400.

%% Calculate statistics
 s=[reshape(AIfdbk1,450,200*24),reshape(AIfdbk2,450,200*24)];
 mr=[reshape(AImresp1,450,200*24),reshape(AImresp2,450,200*24)];
 tic;stAI_PSCR=AI_stats(s,mr);toc

% Elapsed_time = 129.5370 (2 min) on a Dell Optiplex GX400.

 sstAI24_PSCR=AI_summary(stAI_PSCR)
sstAI24_PSCR =
    resp_mean: [5.0300 0.1180 5.0268 0.0378 4.8822 5.0267 5.2067]
     resp_std: [2.4040 0.0870 2.4967 0.0405 2.3579 2.4949 2.6362]
           R2: [0.9010 0.0350 0.8848 0.0324 0.7665 0.8825 0.9601]
            T: [1.6850 0.2070 1.5679 0.1996 1.0990 1.5227 2.1703]
          bow: [0.1420 0.4030 -0.2679 0.3259 -1.4084 -0.2780 1.1234]
           pr: [0.0650 0.1230 0.0109 0.0729 -0.2778 0.0111 0.2444]
       deltaS: [0.0220 0.1580 0.0220 0.0965 -0.3345 0.0204 0.4097]
     deltaARL: [0.0200 0.2220 -0.0031 0.1192 -0.4492 -0.0032 0.4941]
          rep: [0.1150 0.0860 0.0098 0.0735 -0.2368 0.0101 0.3152]
         rrep: [0.6460 0.0900 0.5399 0.0986 0.2353 0.5333 0.9268]
         nrep: [0.5310 0.0840 0.5301 0.0742 0.3416 0.5152 0.7531]
WARNING: The sign of the context measure d is reversed in the manuscript.  WARNING
            d: [-0.1450 0.2440 -0.0023 0.2067 -0.9202 -0.0013 0.7696]
           d1: [-0.2330 0.2150 -0.0047 0.2084 -0.9055 -0.0047 0.7627]
           d2: [-0.0570 0.2490 1.5489e-004 0.2050 -0.9202 0.0031 0.7696]
     mn_scale: [1.381 2.231 3.161 4.120 5.082 6.037 6.957 7.810 8.463]
     mn_stdev: [0.629 0.727 0.785 0.836 0.883 0.915 0.921 0.879 0.729]
     mn_Pcorr: [0.695 0.622 0.556 0.506 0.472 0.448 0.440 0.454 0.588]
    mn_dprime: [1.8433 1.6092 1.4445 1.3269 1.2318 1.1448 1.0808 1.0191]
    mn_blkacc: [0.5223 0.5333 0.5334 0.5339 0.5332]
    mn_blkstd: [2.5128 2.1750 2.4900 2.1752 2.4908]
       mn_ARL: [5.027 5.025 5.042 5.047 5.021 5.022 5.040 5.042 5.023 5.023;
                5.029 5.026 5.042 5.042 5.025 5.024 5.048 5.042 5.025 5.022]

 fprintf('%.3f ',sstAI24_PSCR.mn_scale)
 fprintf('%.3f ',sstAI24_PSCR.mn_stdev)
 fprintf('%.3f ',sstAI24_PSCR.mn_Pcorr)
 a=sstAI24_PSCR.mn_ARL;fprintf('%.3f ',a(1,:));fprintf('\n');fprintf('%.3f ',a(2,:));
 save sstAI24_PSCR sstAI24_PSCR


*************************************************************
***                ******************************************
***   Model PSACR  = full ANCHOR model **********************
***   Abs. Ident   ******************************************
***                ******************************************
*************************************************************
4 Jan 2004

Active parameters:  mem_k, temper, cutoff, hist
Fixed parameters:   perc_k=0.04, decay=0.5, alpha=0.3
                    cutoff multipliers=[-3 -1 +0.9 +2.7]
                    only two anchors initially: L1=.275, L9=.675

 cd 'C:\work\anchor\finalsim\' ; load hier_stimuli ;
 load hier_opt_params ;      % resAI24_PSACR, among others

%% Optimal AI params
 resAI=resAI24_PSACR ; v2p=resAI.search_params.v2p_templ;v2p'
ans = 'PARAMS.mem_k = VAL / 10 ;'
      'PARAMS.temper = VAL / 10 ;'
      'PARAMS.history = VAL / 5 ;'
      'PARAMS.cutoffs = VAL*[-3 -1 +0.9 +2.7] ;'

% Convert the CORRECTED parameters. See the post-optimization
% correction for Models PSCR and PSACR in HRAI_PSEARCH.TXT.
 p0=resAI.search_params.params;x=resAI.corr_X;describe(x)
    Mean  Std.dev       Min     Q25  Median     Q75     Max
------------------------------------------------------------
   0.582    0.244      0.30    0.30    0.60    0.82    0.89  % mem_k * 10
   0.495    0.086      0.40    0.40    0.46    0.59    0.60  % temper* 10
   0.356    0.179      0.25    0.25    0.25    0.37    0.83  % history* 5
   0.720    0.188      0.50    0.59    0.65    0.87    1.04  % cutoff

 for k=1:24 AI_params(k)=vector2params(x(k,:),p0,v2p);end;AI_params(24)
AI_params(24) =
       scale: 'LINEAR'
       N_cat: 9
     SM_conv: 0.0010
      cat_sz: 0.0500
      perc_k: 0.0400
       mem_k: 0.0734
       avail: [2x1 double]
     anchors: [9x6 double]
     cutoffs: [-1.6127 -0.5376 0.4838 1.4514]
      temper: 0.0447
     history: 0.0500
       alpha: 0.3000
       decay: 0.5000
         ITI: 4
    M_raster: 7
    A_raster: [5 5 3 3]
    mnfieldp: 1

 AI_params(24).anchors(:,1)'
ans = [0.2750 0.3250 0.3750 0.4250 0.4750 0.5250 0.5750 0.6250 0.6750]

%% Run the model
 AIfdbk1=(AIstim1-225)./50 ; AIfdbk2=(AIstim2-225)./50 ;
 AImresp1=zeros(size(AIstim1));AImresp2=zeros(size(AIstim2));
 tic; for k=1:24;fprintf('%d ',k);p=AI_params(k);
    AImresp1(:,:,k)=anchor2(AIstim1(:,:,k),p,AIfdbk1(:,:,k));
    AImresp2(:,:,k)=anchor2(AIstim2(:,:,k),p,AIfdbk2(:,:,k)); end;toc

% Elapsed_time =  892.8440 (15 min) on a Dell Optiplex GX400.

%% Calculate statistics
 s=[reshape(AIfdbk1,450,200*24),reshape(AIfdbk2,450,200*24)];
 mr=[reshape(AImresp1,450,200*24),reshape(AImresp2,450,200*24)];
 tic;stAI_PSACR=AI_stats(s,mr);toc

% Elapsed_time = 130.3680 (2 min) on a Dell Optiplex GX400.

 sstAI24_PSACR=AI_summary(stAI_PSACR)
sstAI24_PSACR =
    resp_mean: [5.0300 0.1180 5.0307 0.0513 4.8356 5.0289 5.2844]
     resp_std: [2.4040 0.0870 2.5043 0.0422 2.3514 2.5069 2.6383]
           R2: [0.9010 0.0350 0.8860 0.0340 0.7589 0.8848 0.9611]
            T: [1.6850 0.2070 1.5717 0.2017 1.0876 1.5302 2.2059]
          bow: [0.1420 0.4030 -0.3066 0.3252 -1.3465 -0.3127 1.0669]
           pr: [0.0650 0.1230 0.0192 0.0739 -0.3111 0.0222 0.2667]
       deltaS: [0.0220 0.1580 0.0112 0.0988 -0.3768 0.0110 0.4498]
     deltaARL: [0.0200 0.2220 -0.0031 0.1225 -0.6215 -0.0018 0.4902]
          rep: [0.1150 0.0860 0.0431 0.0752 -0.2326 0.0434 0.3442]
         rrep: [0.6460 0.0900 0.5670 0.0976 0.2609 0.5636 0.9167]
         nrep: [0.5310 0.0840 0.5239 0.0745 0.3406 0.5087 0.7606]
WARNING: The sign of the context measure d is reversed in the manuscript.  WARNING
            d: [-0.1450 0.2440 -0.1148 0.2172 -1.2593 -0.1070 0.6993]
           d1: [-0.2330 0.2150 -0.1159 0.2194 -1.2593 -0.1094 0.6993]
           d2: [-0.0570 0.2490 -0.1137 0.2149 -1.0037 -0.1045 0.6144]
     mn_scale: [1.357 2.217 3.166 4.129 5.094 6.054 6.979 7.821 8.461]
     mn_stdev: [0.602 0.713 0.774 0.833 0.886 0.924 0.929 0.883 0.721]
     mn_Pcorr: [0.709 0.621 0.561 0.503 0.468 0.440 0.434 0.438 0.586]
    mn_dprime: [1.8562 1.6450 1.4473 1.3183 1.2172 1.1239 1.0483 0.9701]
    mn_blkacc: [0.5141 0.5359 0.5288 0.5317 0.5333]
    mn_blkstd: [2.5122 2.1577 2.4897 2.1814 2.5009]
       mn_ARL: [5.032 5.030 5.111 5.156 5.100 5.086 5.067 5.040 5.027 5.027;
                5.033 5.031 4.985 4.943 4.954 4.967 5.033 5.057 5.031 5.029]

 fprintf('%.3f ',sstAI24_PSACR.mn_scale)
 fprintf('%.3f ',sstAI24_PSACR.mn_stdev)
 fprintf('%.3f ',sstAI24_PSACR.mn_Pcorr)
 a=sstAI24_PSACR.mn_ARL;fprintf('%.3f ',a(1,:));fprintf('\n');fprintf('%.3f ',a(2,:));
 save sstAI24_PSACR sstAI24_PSACR

%%
%%%%%%%%%%%  End of file HRAI_MSTATS.TXT
