Home > wafo > wstats > yates.m

# yates

## PURPOSE

Calculates main and interaction effects using Yates' algorithm.

## SYNOPSIS

[ef, id]=yates(y,varargin)

## DESCRIPTION

YATES Calculates main and interaction effects using Yates' algorithm.

CALL:  [ef, id] = yates(y);

id = identification vector of main and interaction effects.
ef = vector of average response, main effects and interaction effects.
y  = calculated response from a two-level complete factorial design.

YATES applies the  Yates' algorithm to the responses Y to obtain
average response, main effects and interaction effects. Y is assumed to
be arranged in what is called standard order. (The order of the actual
running should, of course, be random).  EF(1,:) is the
average response and EF(2:end,:) contain the main effects and
interaction effects corresponding to the vector ID.

YATES may also be used in analyzing data from any 2^(K-P) fractional
factorial design. The algorithm is applied in the usual way to any ambedded
complete factorial in K-P factors, i.e., the responses must be
rearranged so that K-P factors is a complete factorial in standard order.
Then associate the calculated effects with their appropriate aliases
using ALIAS.

Example:
y = [60 72 54 68 52 83 45 80]; % Responses to design D.
[ef,id] = yates(y);

I = sudg(7,4);
y1 = [69 52 60 83 71 50 59 88]; % Responses to design D1.
[ef1,id1] = yates(y1);
alias(cdr(I),3)                 % associate with id1

## CROSS-REFERENCE INFORMATION

This function calls:
 cnr2cl Column Number to Column Label. error Display message and abort function. sortrows Sort rows in ascending order.
This function is called by:
 fitmodel Fits response by polynomial nplot Normal probability plot of effects ryates Reverse Yates' algorithm to give estimated responses

## SOURCE CODE

001 function [ef, id]=yates(y,varargin)
002 %YATES Calculates main and interaction effects using Yates' algorithm.
003 %
004 % CALL:  [ef, id] = yates(y);
005 %
006 %  id = identification vector of main and interaction effects.
007 %  ef = vector of average response, main effects and interaction effects.
008 %  y  = calculated response from a two-level complete factorial design.
009 %
010 % YATES applies the  Yates' algorithm to the responses Y to obtain
011 % average response, main effects and interaction effects. Y is assumed to
012 % be arranged in what is called standard order. (The order of the actual
013 % running should, of course, be random).  EF(1,:) is the
014 % average response and EF(2:end,:) contain the main effects and
015 % interaction effects corresponding to the vector ID.
016 %
017 % YATES may also be used in analyzing data from any 2^(K-P) fractional
018 % factorial design. The algorithm is applied in the usual way to any ambedded
019 % complete factorial in K-P factors, i.e., the responses must be
020 % rearranged so that K-P factors is a complete factorial in standard order.
021 % Then associate the calculated effects with their appropriate aliases
022 % using ALIAS.
023 %
024 % Example:
025 %   D = ffd(3);                    % complete 2^3 design in standard order.
026 %   y = [60 72 54 68 52 83 45 80]; % Responses to design D.
027 %   [ef,id] = yates(y);
028 %
029 %   I = sudg(7,4);
031 %   y1 = [69 52 60 83 71 50 59 88]; % Responses to design D1.
032 %   [ef1,id1] = yates(y1);
033 %   alias(cdr(I),3)                 % associate with id1
034 %
036
037
038
039 % Reference
040 % Box, G.E.P, Hunter, W.G. and Hunter, J.S. (1978)
041 % Statistics for experimenters, John Wiley & Sons, pp 342
042
043 % Tested on: Matlab 5.3
044 % History:
045 % By Per A. Brodtkorb 16.03.2001
046
047 error(nargchk(1,2,nargin))
048 sz = size(y);
049 n  = length(y);
050 if prod(sz) == n,
051   y = y(:);       % Make sure it is a column vector
052 else
053   n = sz(1);      % Number of runs
054 end
055
056 k = log2(n);      % Number of variables.
057 if round(k)~=k, error('The length of y must be in power of two'), end
058
059 % Yates algorithm:
060 %--------------------------
061 ef   = y;
062 ind2 = 2:2:n;
063 ind1 = 1:2:n-1;
064 for ix=1:k
065   ef = [ef(ind2,:)+ef(ind1,:); ef(ind2,:)-ef(ind1,:)];
066 end
067 ef = ef*(2/n);
068 ef(1,:) = ef(1,:)/2;
069
070
071 if nargout>1,
072   id = zeros(n-1,k);
073   iz = 0;
074   for ix = 1:k,
075     iz       = iz+1;
076     id(iz,1) = ix;
077     iz0      = iz;
078     for iy = 1:iz0-1,
079       iz = iz+1;
080       id(iz,:)   = id(iy,:);
081       ind        = min(find(id(iy,:)==0));
082       id(iz,ind) = ix;
083     end
084   end
085   if nargin>1, % secret option
086     % Sort effects
087     [id, ind] = sortrows(fliplr(id));
088     id = fliplr(id);
089     ef(2:end,:) = ef(ind+1,:);
090   end
091   % String representation
092   id = cnr2cl(id);
093   %str0=[' ',char(65:90) char(97:122)]; % characters A - Z a-z
094   %id = str0(id+1);
095 end
096
097
098 return
099
100
101
102
103

Mathematical Statistics
Centre for Mathematical Sciences
Lund University with Lund Institute of Technology

Comments or corrections to the WAFO group

Generated on Thu 06-Oct-2005 02:21:16 for WAFO by m2html © 2003