📄 tucker3.m
字号:
cc=input(' If you want to renormalize components, specify "1": ');
if isempty(cc);cc=0;end;
renormmode=0;
disp(' ');
if cc==1
renormmode=input(' Which mode do you want to renormalize? Enter 1 (=A), 2 (=B) or 3 (=C): ');
[A,B,C,H]=renormsol(A,B,C,H,renormmode);
end;
disp(' ');
disp(' Find useful simple structure rotation of core and components');
disp(' ');
disp(' ');
cc=1;
while cc==1
% varimcocoruns.m
% program to run varimcoco repeatedly with different
% relative weights for A,B,C
disp(' ');
disp(' You can now carry out SIMPLE STRUCTURE rotations with varying weights;');
disp(' if desired, you can specify a range of different weights for each mode.');
disp(' To specify a range of values you type, e.g., 1:4 (then the values 1,2,3 and 4 are chosen),');
disp(' or 1:5:25 (then the values 1,6,11,16 and 21 are chosen),');
disp(' or [1 2 5 10 100] (then the values 1,2,5,10 and 100 are chosen).');
disp(' You can also specify a single weight (e.g., just 1).');
disp(' Analyses will be carried out with all combinations of relative weights.');
disp(' ');
aa=input(' Specify (range of) relative weight(s) for A: ');
bb=input(' Specify (range of) relative weight(s) for B: ');
cc=input(' Specify (range of) relative weight(s) for C: ');
disp(' ');
out=[];
if isempty(aa);aa=0;end;
if isempty(bb);bb=0;end;
if isempty(cc);cc=0;end;
for wa_rel=aa
for wb_rel=bb
for wc_rel=cc
disp(' ');
disp(' ');
fprintf(' Simple structure rotation with relative weights %g %g %g \n',wa_rel,wb_rel,wc_rel);
disp(' ');
[AS,BT,CU,K,S,T,U,f,f1,f2a,f2b,f2c,func]=varimcoco(A,B,C,H,wa_rel,wb_rel,wc_rel);
out=[out;wa_rel wb_rel wc_rel f1 f2a f2b f2c];
end;
end;
end;
disp(' ');
disp(' relative weights simplicity values');
disp(' A B C core A B C');
disp(' ');
writescr(out,'6.2');
disp(' ');
ccc=input(' If you want to temporarily leave the program, specify "1": ');
if isempty(ccc);ccc=0;end;
if ccc==1,
disp(' ');
disp(' You leave the interactive program and can manipulate/study current matrices ');
disp(' To return to interactive program, type "return"');
keyboard;
end;
ccc=input(' If you want another series of simple structure analyses, specify "1": ');
if isempty(ccc);ccc=0;end;
if ccc~=1,cc=2;end;
end;
disp(' ');
disp(' Give SIMPLE STRUCTURE rotated solution(s) in detail ');
disp(' ');
cc=1;
% make labels for columns of core
str=[' '];
for k=1:r3
for j=1:r2
str=[str ' B' int2str(j) 'xC' int2str(k)];
end;
end;
corelabelstr=str;
while cc==1
disp(' Use last simple structure rotated solution ? type "return"');
cc=input(' to specify a different simple structure rotation, specify "1" ');
if isempty(cc),cc=0;end;
if cc==1
disp(' Specify your choice for the preferred simple structure rotation of core and components');
wa_rel=input(' Specify relative weight for simplicity of A-mode ');
wb_rel=input(' Specify relative weight for simplicity of B-mode ');
wc_rel=input(' Specify relative weight for simplicity of C-mode ');
disp(' ');
[AS,BT,CU,K,S,T,U,f,f1,f2a,f2b,f2c,func]=varimcoco(A,B,C,H,wa_rel,wb_rel,wc_rel);
end;
disp(' ');
disp(' Backnormalize A,B,C, and H');
if renormmode==1
Ds=diag(sum(AS.^2).^.5);
AS=AS/Ds;
K=Ds*K;
end;
if renormmode==2
Ds=diag(sum(BT.^2).^.5);
BT=BT/Ds;
K=K*kron(eye(r3),Ds);
end;
if renormmode==3
Ds=diag(sum(CU.^2).^.5);
CU=CU/Ds;
K=K*kron(Ds,eye(r2));
end;
disp(' ');
disp(' Rotated Solution for A, B and C is in AS, BT and CU');
disp(' Rotated core in K');
disp(' ');
if n<40,disp(' ');disp(' Rotated A (AS) ');disp(' ');writescr(AS,'6.2');end
disp(' ');disp(' Rotated B (BT) ');disp(' ');writescr(BT,'6.2')
disp(' ');disp(' Rotated C (CU) ');disp(' ');writescr(CU,'6.2')
disp(' ');disp(' Rotated core');disp(' ');disp(corelabelstr);disp(' ');writescr(K,'8.2')
disp(' ');
cc=0;
disp(' You can keep present as final solution, or study a different one');
cc=input(' If you want to study one more solution, specify "1" ');
end;
% manual permutation and reflection:
disp(' ');
disp(' You can now manually PERMUTE and REFLECT columns/rows of solution');;
disp(' ');
cc=input(' If you want to reflect/permute columns/rows, specify "1": ');
if isempty(cc);cc=0;end;
while cc==1
tau=[];pp=[];
disp(' ');
tau=input(' Give vector for reflection of columns of A (e.g., [1 -1 -1 1 ..]) ');
if isempty(tau),tau=ones(1,r1);end;
if ssq(tau)~=r1,disp(' incorrect reflection');tau=ones(1,r1);end;
if ssq(tau.^2-1)~=0,disp(' incorrect reflection');tau=ones(1,r1);end;
disp(' ');
pp=input(' Give vector with new order of columns of A (e.g., [3 1 4 2 ..]) ');
if isempty(pp),pp=1:r1;end;
if ssq(size(pp)-size(ones(1,r1)))>0,disp(' incorrect permutation');pp=1:r1;end;
if ssq(sort(pp')'-[1:r1])>0,disp(' incorrect permutation');pp=1:r1;end;
AS=AS*diag(tau);K=diag(tau)*K;
AS=AS(:,pp);K=K(pp,:);
disp(' ');disp(' Rotated B (BT) ');disp(' ');writescr(BT,'6.2')
disp(' ');disp(' Rotated C (CU) ');disp(' ');writescr(CU,'6.2')
disp(' ');disp(' Rotated core');disp(' ');disp(corelabelstr);disp(' ');writescr(K,'8.2')
tau=[];pp=[];
disp(' ');
tau=input(' Give vector for reflection of columns of B (e.g., [1 -1 -1 1 ..]) ');
if isempty(tau),tau=ones(1,r2);end;
if ssq(tau)~=r2,disp(' incorrect reflection');tau=ones(1,r2);end;
if ssq(tau.^2-1)~=0,disp(' incorrect reflection');tau=ones(1,r2);end;
disp(' ');
pp=input(' Give vector with new order of columns of B (e.g., [3 1 4 2 ..]) ');
if isempty(pp),pp=1:r2;end;
if ssq(size(pp)-size(ones(1,r2)))>0,disp(' incorrect permutation');pp=1:r2;end;
if ssq(sort(pp')'-[1:r2])>0,disp(' incorrect permutation');pp=1:r2;end;
K=permnew(K,r1,r2,r3);
BT=BT*diag(tau);K=diag(tau)*K;
BT=BT(:,pp);K=K(pp,:);
K=permnew(K,r2,r3,r1);
K=permnew(K,r3,r1,r2);
disp(' ');
disp(' ');disp(' Rotated C (CU) ');disp(' ');writescr(CU,'6.2')
disp(' ');disp(' Rotated core');disp(' ');disp(corelabelstr);disp(' ');writescr(K,'8.2')
tau=[];pp=[];
disp(' ');
tau=input(' Give vector for reflection of columns of C (e.g., [1 -1 -1 1 ..]) ');
if isempty(tau),tau=ones(1,r3);end;
if ssq(tau)~=r3,disp(' incorrect reflection');tau=ones(1,r3);end;
if ssq(tau.^2-1)~=0,disp(' incorrect reflection');tau=ones(1,r3);end;
disp(' ');
pp=input(' Give vector with new order of columns of C (e.g., [3 1 4 2 ..]) ');
if isempty(pp),pp=1:r3;end;
if ssq(size(pp)-size(ones(1,r3)))>0,disp(' incorrect permutation');pp=1:r3;end;
if ssq(sort(pp')'-[1:r3])>0,disp(' incorrect permutation');pp=1:r3;end;
K=permnew(K,r1,r2,r3);
K=permnew(K,r2,r3,r1);
CU=CU*diag(tau);K=diag(tau)*K;
CU=CU(:,pp);K=K(pp,:);
K=permnew(K,r3,r1,r2);
disp(' ');disp(' Rotated C (CU) ');disp(' ');writescr(CU,'6.2')
disp(' ');disp(' Rotated core');disp(' ');disp(corelabelstr);disp(' ');writescr(K,'8.2')
disp(' ');
disp(' ');
cc=input(' If you want to further reflect/permute columns/rows, specify "1": ');
if isempty(cc);cc=0;end;
end;
if n<40,disp(' ');disp(' Rotated A (AS) ');disp(' ');writescr(AS,'6.2',laba);end
disp(' ');disp(' Rotated B (BT) ');disp(' ');writescr(BT,'6.2',labb);
disp(' ');disp(' Rotated C (CU) ');disp(' ');writescr(CU,'6.2',labc);
disp(' ');disp(' Rotated core');disp(' ');disp(corelabelstr);disp(' ');writescr(K,'8.2')
disp(' ');
disp(' ');
disp(' You can produce a JOINT PLOT now');
disp(' In joint plots, one mode is fixed, while the entities of the other two are plotted');
cc=input(' If you want to produce a joint plot for the current solution, specify "1": ');
if isempty(cc);cc=0;end;
while cc==1
fixmode=input(' Which mode do you want to keep fixed ("1", "2" or "3")? ');
if fixmode==1 |fixmode==2 |fixmode==3
fixunit=input(' For which component do you want to see the joint plot? ');
fs=7; % fontsize fixed to 7
fit=jointplotgen(K,AS,BT,CU,fixmode,fixunit,laba,labb,labc,fs);
disp(' ');
fprintf(' The plot displays %4.2f %% of the information represented by the component of your choice\n',fit);
disp(' ');
else
disp(' fixed mode specified wrongly');
end;
disp(' ');
cc=0;
cc=input(' Do you want to produce another joint plot? If so, type "1": ');
disp(' ');
end;
disp(' ');
disp(' ');
ccc=1;
while ccc==1
disp(' If you want to carry out a BOOTSTRAP procedure for ');
ccc=input(' computing confidence intervals for the current solution, specify "1": ');
if isempty(ccc);ccc=0;end;
if ccc==1
disp(' It is assumed that the A-mode is the mode from which you want to resampling');
disp(' If this is not the case, first reorder your data');
A=AS;B=BT;C=CU;G=K;
disp(' Procedure uses optimal matching of bootstrap solutions to original solution');
optimalmatch=1; % for specialized use, one may change this into 0,
% to get orthogonal rotations
bootstraptucker3
% make labels for columns of core
str=[''];
for k=1:r3
for j=1:r2
str=[str ' B' int2str(j) 'xC' int2str(k) ' '];
end;
end;
corelabelstr2=str;
% make labels for intervals of columns of B and C
strB=[' '];
strC=[' '];
for j=1:r2
strB=[strB ' comp. ' int2str(j)];
end;
for k=1:r3
strC=[strC ' comp. ' int2str(k)];
end;
disp(' ');disp(' Bootstrap confidence intervals for fit percentage ');disp(' ');writescr([lo_fp up_fp],'6.2')
disp(' ');disp(' Bootstrap confidence intervals for B, per component next to each other ');disp(' ');disp(strB);disp(' ');writescr(Bint,'6.2',labb);
disp(' ');disp(' Bootstrap confidence intervals for C, per component next to each other ');disp(' ');disp(strC);disp(' ');writescr(Cint,'6.2',labc);
disp(' ');disp(' Bootstrap confidence intervals for Core ');disp(' ');disp(corelabelstr2);disp(' ');writescr(Gint,'6.2')
disp(' ');
ccc=0;
end;
end;
disp(' ');
ccc=1;
while ccc==1
ccc=input(' If you want to carry out a STABILITY CHECK on current or different solution, specify "1": ');
if isempty(ccc);ccc=0;end;
if ccc==1
splithalft3
end;
end;
disp(' ');
disp(' ');
disp(' Press any key to conclude analysis with FITPARTITIONING');
pause;
disp(' ');
% computation of residuals (on Res) and partitioning of fit
disp(' ');
disp(' Contribution to fit (in %s) for all combinations of components');
disp(' These contributions can simply be added to get aggregate contributions of in case all components are orthogonal');
disp(' If this is not the case, aggregate fit contributions are given separately, below');
ssqX=ssq(Xprep);
disp(' ');disp(corelabelstr);disp(' ');writescr((K.^2)*100/ssqX,'8.2');
[fitA,fitB,fitC,BCcontr,ACcontr,ABcontr]=t3fitpartitioning(Xprep,n,m,p,AS,BT,CU,K,renormmode);
if n<40
disp(' ');
disp(' Relative fit of A-mode entities (in %)');
disp(' ');
writescr(fitA,'6.1',laba);
end;
disp(' ');
disp(' Relative fit of B-mode entities (in %)');
disp(' ');
writescr(fitB,'6.1',labb);
disp(' ');
disp(' Relative fit of C-mode entities (in %)');
disp(' ');
writescr(fitC,'6.1',labc);
disp(' ');
disp(' NOTE: Residuals on "Res", can be used for further analyses');
disp(' ');
disp(' Full rotated solution can be found in AS,BT,CU,K');
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -