As a more complete, if a little pedestrian, example of a function, consider
finding the efficiency factors for a block design. (Some aspects of this
problem have already been discussed in §
.)
A block design is defined by two factor, say blocks (b levels)
and varieties, (v levels). If
and
are the replications and block size matrices, and
is the incidence matrix, then the efficiency factors are
defined as the eigenvalues of the matrix

where
. One way to write the function is as in
Figure 5.
Figure 5: A function for block design efficiencies
It is numerically slightly better to work with the singular value decomposition on this occasion rather than the eigenvalue routines.
The result of the function is a list giving not only the efficiency factors as the first component, but also the block and variety cononical contrasts, since sometimes these give additional useful qualitative information.