function [a,b] = regcon(mod,xmn,ymn,xst,yst); %REGCON Converts regression model to y = ax + b form % REGCON can be used to convert a model (mod) generated by the % the function MODLMKER or MODLGUI. The outputs are the % regression coefficients (a) and the intercept (b) % such that y = ax + b. In this case the I/O syntax is: % % [a,b] = regcon(mod); % % REGCON can also be used to convert the individual parts of a % regression model, including the column vector of regression % coefficients (regv), predictor variable means (xmn), % predicted variable means (ymn), predictor variable scaling % (xst), and predicted variable scaling (yst). If xmn or ymn % is not supplied or is set equal to 0 or [], then it is assumed % to be zero (i.e. no centering was used in the model). If xst % or yst is not supplied or is set equal to 0 or [], then it is % assumed to be one (i.e. no scaling was used in the model). % In this case the I/0 syntax is: % % [a,b] = regcon(regv,xmn,ymn,xst,yst); % % Examples: % [a,b] = regcon(mod); % using MODLMKER model % [a,b] = regcon(regv,xmn,ymn); % mean centered only % [a,b] = regcon(regv,xmn,ymn,xst,yst); % mean centered and scaled % [a,b] = regcon(regv,xmn,ymn,[],yst); % x data centered but not scaled % [a,b] = regcon(regv,0,0,xst,yst); % x and y scaled by not centered % % See also MODLPRED, MODLRDER, MODLMKER, MODLGUI, MODLPARS, % PLS, CONPRED1, PCR, RIDGE, AUTO, MNCN % Copyright Eigenvector Research 1997 % by BM Wise, July, 1997 if (nargin < 2 & any([mod(1,11) == 1 mod(1,11) == 2 mod(1,11) == 3])) [xmn,ymn,xst,yst,bb,p,w,tsq,q] = modlpars(mod); nxv = mod(1,8); nyv = mod(1,10); else bb = mod; [nxv,nyv] = size(mod); if nargin == 1 xmn = 0; ymn = 0; xst = 0; yst = 0; elseif nargin == 2 ymn = 0; xst = 0; yst = 0; elseif nargin == 3 xst = 0; yst = 0; elseif nargin == 4 yst = 0; end end if (xmn == 0 | isempty(xmn)) xmn = zeros(1,nxv); end if (xst == 0 | isempty(xst)) xst = ones(1,nxv); end if (ymn == 0 | isempty(ymn)) ymn == zeros(1,nyv); end if (yst == 0 | isempty(yst)) yst = ones(1,nyv); end b = -((xmn./xst)*bb).*yst + ymn; a = diag(yst)*(bb'./xst(ones(nyv,1),:));