0001 function an_st = ensemble_qid_x_qid_chi2(data,params)
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019 an_st = {};
0020 na = 0;
0021
0022 dcols = set_var_col_const(data{1}.vars);
0023 eqxq_tbls = data{1}.data{dcols.count};
0024
0025 il = length(eqxq_tbls(:,1,1));
0026 jl = length(eqxq_tbls(1,:,1));
0027
0028 df = (il-1)*(jl-1);
0029 chi2 = 0;
0030
0031 ctbl = zeros(il,jl);
0032 ctbli = zeros(il);
0033 ctblj = zeros(jl);
0034 cttl = sum(sum(sum(eqxq_tbls)));
0035
0036 for ii=1:il
0037 ctbli(ii) = sum(sum(eqxq_tbls(ii,:,:)));
0038 for ij=1:jl
0039 ctblj(ij) = sum(sum(eqxq_tbls(:,ij,:)));
0040 ctbl(ii,ij) = sum(eqxq_tbls(ii,ij,:));
0041 chi2e = (ctbli(ii)*ctblj(ij))/cttl;
0042 chi2 = chi2 + (ctbl(ii,ij)-chi2e)^2/chi2e;
0043 end
0044 end
0045
0046 na=na+1;
0047 an_st{na} = init_analysis_struct;
0048 an_st{na}.type = 'ensemble_qid_x_qid_chi2';
0049 an_st{na}.vars = {'chi2','df'};
0050 an_cols = set_var_col_const(an_st{na}.vars);
0051 an_st{na}.data = {};
0052 an_st{na}.data{an_cols.chi2} = chi2;
0053 an_st{na}.data{an_cols.df} = df;
0054
0055 function an_st = init_analysis_struct
0056 an_st.type = '';
0057 an_st.vars = {};
0058 an_st.data = {};
0059 an_st.meta = [];
0060