%----- Compare models by Akaike's AICc : individual fittings versus global one ----
% by Evgenii Kovrigin    3/7/08
% For details of model testing see  {Motulsky, 2004 #4251}
%
%  Here I assume you do fitting of each residue individually with specific
%  model and then do fitting of all of them globally with THE SAME model.
%  If this is not true, if this is fitting with two totally different models
%  - you need to correct how I compute total number of
%  fitting parameters for models 1 and 2.
%
% To use: 
%      - Run  individual and global fitting for a group of residues 
%         NOTE: make sure fits are reasonable!
%
%         Fit_grid_ek.m saves the sum of resudual squares and number of points in
%         the files resname_SS.txt. Look up composite name for the global
%         fitting session in grid_results... file. Put these residue names
%         into the variables below

%
%      -  execute 'compare.m'. Results are displayed and saved into plain
%      text file.

model_setup;

%=======    USER INPUT =======



%-- Enter here data set names from individual fitting sessions
resnames =   char(     'Y92_x_w1',   'T70_x_w1',  'S123_x_w1', 'S123_x_w2', 'H12_x_w2' );

%--- 'global' name from fitting (look up in grid_results... file) ---
global_resname='Y92_x_w1.T70_x_w1.S123_x_w1.S123_x_w2.H12_x_w2';


%-- output file name
outfname='Global_vs_individual_fitting.txt';

%===== END OF USER INPUT =======


%-- NOW YOU CAN ISSUE 'compare' ---






%--- Number of fitting parameters 
Num_Fit_Pars=length(B_vector.starting_values);
