Home > fmri > utils > vanhorn > ANOVATables.m

ANOVATables

PURPOSE ^

ANOVATables(outfile, x, y, z, N, p, Beta, TotalVariance, Fomni, p_int,

SYNOPSIS ^

function ANOVATables(outfile, x, y, z, N, p, Beta, TotalVariance, Fomni, p_int, FReduced, Lambda, LambdaReduced, EplusHReduced,F_contrast,C,C_names)

DESCRIPTION ^

 ANOVATables(outfile, x, y, z, N, p, Beta, TotalVariance, Fomni, p_int,
             FReduced, Lambda, LambdaReduced, EplusHReduced,F_regressor,C,C_names)

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function ANOVATables(outfile, x, y, z, N, p, Beta, TotalVariance, Fomni, p_int, FReduced, Lambda, LambdaReduced, EplusHReduced,F_contrast,C,C_names)
0002 % ANOVATables(outfile, x, y, z, N, p, Beta, TotalVariance, Fomni, p_int,
0003 %             FReduced, Lambda, LambdaReduced, EplusHReduced,F_regressor,C,C_names)
0004 
0005 % 03/24/02 PJ  Fixed handling of contrasts involving more than one regressor.
0006 
0007 % Original script written by Jack Van Horn.
0008 
0009 mode='a';
0010 
0011 fid=fopen(outfile,mode);
0012 
0013 % Omnibus ANOVA Table
0014 ndf=p;
0015 ddf=(N-p-1);
0016 prob=betainc((ddf./(ddf+ndf.*Fomni)),ddf/2,ndf/2);
0017 fprintf(fid,'*************************************************************************\n');
0018 fprintf(fid,'*** Voxel %i, %i, %i Omnibus Analysis of Variance for Regression Table ***\n',x,y,z);
0019 fprintf(fid,'*************************************************************************\n\n');
0020 fprintf(fid,'-------------------------------------------------------------------------\n');
0021 fprintf(fid,'Source\t\tdf\t\tSS\t\tF\t\tp\n');
0022 fprintf(fid,'-------------------------------------------------------------------------\n');
0023 fprintf(fid,'Regression\t%i\t\t%8.4f\t%8.4f\t\t%6.5f\n', p, (1-Lambda)*TotalVariance, Fomni, prob);
0024 fprintf(fid,'Error\t\t%i\t\t%8.4f\n', (N-p-1), Lambda*TotalVariance);
0025 fprintf(fid,'-------------------------------------------------------------------------\n');
0026 fprintf(fid,'Total\t\t%i\t\t%8.4f\n', (N-1), TotalVariance);
0027 fprintf(fid,'-------------------------------------------------------------------------\n');
0028 fprintf(fid,'R-Squared = %f\n',1-Lambda);
0029 fprintf(fid,'R-Squared Adjusted for Shrinkage= %f\n\n',1-Lambda*(N-1)/(N-p-1));
0030 
0031 % Reduced Model ANOVA Table
0032 ndf=p_int;
0033 ddf=(N-p-1);
0034 prob=betainc((ddf./(ddf+ndf.*FReduced)),ddf/2,ndf/2);
0035 fprintf(fid,'*******************************************************************************\n');
0036 fprintf(fid,'*** Voxel %i, %i, %i Reduced Model Analysis of Variance for Regression Table ***\n',x,y,z);
0037 fprintf(fid,'*******************************************************************************\n\n');
0038 fprintf(fid,'-------------------------------------------------------------------------\n');
0039 fprintf(fid,'Source\t\tdf\t\tSS\t\tF\t\tp\n');
0040 fprintf(fid,'-------------------------------------------------------------------------\n');
0041 fprintf(fid,'Regression\t%i\t\t%8.4f\t%8.4f\t\t%6.5f\n', p_int, (1-LambdaReduced)*EplusHReduced, FReduced, prob);
0042 fprintf(fid,'Error\t\t%i\t\t%8.4f\n', (N-p-1), LambdaReduced*EplusHReduced);
0043 fprintf(fid,'-------------------------------------------------------------------------\n');
0044 fprintf(fid,'Total\t\t%i\t\t%8.4f\n', (N-1), EplusHReduced);
0045 fprintf(fid,'-------------------------------------------------------------------------\n');
0046 fprintf(fid,'Reduced Model R-Squared = %f\n', 1-LambdaReduced);
0047 fprintf(fid,'Reduced Model R-Squared Adjusted for Shrinkage= %f\n\n', 1-LambdaReduced*(N-1)/(N-p-1));
0048 fprintf(fid,'-------------------------------------------------------------------------\n');
0049 fprintf(fid,'Regression Parameters for Variables Remaining in Model:\n');
0050 
0051 % Individual contrasts
0052 ncont = size(C,1);
0053 if ~exist('C_names')
0054   [C_names(1:ncont)] = deal({''});
0055 end
0056 
0057 for icont=1:ncont
0058   ndf=p-sum(C(icont,:));
0059   ddf=(N-p-1);
0060   prob=betainc((ddf./(ddf+ndf.*F_contrast(icont))),ddf/2,ndf/2);
0061   
0062   % If this is a test of a single regressor, show the beta value
0063   if ndf == 1
0064     reg_idx = find(~C(icont,:));
0065     fprintf(fid,'Model: %s\tRegressor %i:\tBeta = %f, F(1,%i) = %8.4f, p = %f\n', C_names{icont}, reg_idx, Beta(reg_idx), (N-p-1), F_contrast(icont), prob);
0066   else
0067     fprintf(fid,'Model: %s\t, F(%d,%d) = %8.4f, p = %f\n', C_names{icont}, ndf, ddf, F_contrast(icont), prob);
0068   end
0069 end
0070 fprintf(fid,'\n\n#########################################################################\n\n\n');
0071 
0072 fclose(fid);

Generated on Wed 20-Sep-2023 04:00:50 by m2html © 2003