⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 pfplot.m

📁 多维数据处理:MATLAB源程序用于处理多维数据
💻 M
字号:
function pfplot(X,DimX,Factors,Weights,Option);%% $ Version 1.02 $ Date 28. July 1998 $ Not compiled $% $ Version 1.03 $ Date 6. October 1999 $ Changed to handle missing values correctly$%% See also:% 'parafac'%% Copyright, 1998 - % This M-file and the code in it belongs to the holder of the% copyrights and is made public under the following constraints:% It must not be changed or modified and code cannot be added.% The file must be regarded as read-only. Furthermore, the% code can not be made part of anything but the 'N-way Toolbox'.% In case of doubt, contact the holder of the copyrights.%% Rasmus Bro% Chemometrics Group, Food Technology% Department of Food and Dairy Science% Royal Veterinary and Agricultutal University% Rolighedsvej 30, DK-1958 Frederiksberg, Denmark% Phone  +45 35283296% Fax    +45 35283245% E-mail rb@kvl.dk%%% pfplot(X,DimX,Factors,Weights,Option);% Different aspects for evaluation of the solution.%% Option # = 1% 1	NOT ACCESIBLE% 2	NOT ACCESIBLE% 3	DIAGONALITY PLOT% 4	PLOTS OF RESIDUAL VARIANCE% 5	PLOTS OF LEVERAGE% 6	RESIDUALS (STANDARD DEVIATION) VERSUS LEVERAGE% 7	NORMAL PROBABILITY PLOT% 8	LOADING PLOT
factors = Factors;ord=length(DimX);Fac=length(factors)/sum(DimX);lidx(1,:)=[1 DimX(1)*Fac];for i=2:ord  lidx=[lidx;[lidx(i-1,2)+1 sum(DimX(1:i))*Fac]];endif Option(3)==1 % ESTIMATE DIAGONALITY OF T3-CORE diagonality=corcond(X,DimX,Fac,factors,Weights,1);endmodel=nmodel(factors,DimX,Fac);if Option(4)==1% PLOTS OF RESIDUAL VARIANCE  figure,eval(['set(gcf,''Name'',''Residual variance'');']);  aa=ceil(sqrt(ord));bb=ceil(ord/aa);  for i=1:ord    r=nshape(X-model,DimX,i)';    varian=stdnan(r).^2;    subplot(aa,bb,i)      plot(varian)      if DimX(i)<30        hold on        plot(varian,'r+')      end      eval(['xlabel(''Mode ', num2str(i),''');']);      ylabel('Residual variance');  endendif Option(5)==1% PLOTS OF LEVERAGEfigureeval(['set(gcf,''Name'',''Leverage'');']);aa=ceil(sqrt(ord));bb=ceil(ord/aa);for i=1:ord  A=reshape(factors(lidx(i,1):lidx(i,2)),DimX(i),Fac);  lev=diag(A*pinv(A'*A)*A');  subplot(aa,bb,i)  plot(lev,'+')  for j=1:DimX(i)    text(j,lev(j),num2str(j))  end  eval(['xlabel(''Mode ', num2str(i),''');']);  ylabel('Leverage');endendif Option(6)==1% RESIDUALS (STANDARD DEVIATION) VERSUS LEVERAGEfigureeval(['set(gcf,''Name'',''Residuals vs. Leverages'');']);aa=ceil(sqrt(ord));bb=ceil(ord/aa);for i=1:ord  subplot(aa,bb,i)  A=reshape(factors(lidx(i,1):lidx(i,2)),DimX(i),Fac);  lev=diag(A*pinv(A'*A)*A')';  r=nshape(X-model,DimX,i)';  stand=stdnan(r);  plot(lev,stand,'+')  for j=1:DimX(i)    text(lev(j),stand(j),num2str(j))  end  eval(['xlabel(''Leverage in mode ', num2str(i),''');']);  ylabel('Standard deviation');endendif Option(7)==1% NORMAL PROBABILITY PLOTif exist('normplot')    disp(' ')    disp(' Normal probability plots are time-consuming')    disp(' They are made in the statistics toolbox though, so we can''t change that!')    figure,    eval(['set(gcf,''Name'',''Normal probability of residuals'');']);    aa=ceil(sqrt(ord));    bb=ceil(ord/aa);    r=nshape(X-model,DimX,i)';    r=r(:);    normplot(r(find(~isnan(r)))) endendif Option(8)==1% LOADING PLOT  if sum(Option)>1    figure  end  eval(['set(gcf,''Name'',''Loadings'');']);  aa=ceil(sqrt(ord));  bb=ceil(ord/aa);  for i=1:ord    subplot(aa,bb,i)    A=reshape(factors(lidx(i,1):lidx(i,2)),DimX(i),Fac);    plot(A)    eval(['xlabel(''Mode ', num2str(i),''');']);    ylabel('Loading');  endenddrawnow

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -