Visualizing Experimental Designs for Balanced ANOVA Models Using Lisp-Stat

The structure, or Hasse, diagram described by Taylor and Hilton (American Statistician, 1981) provides a visual display of the relationships between factors for balanced complete experimental designs. Using the Hasse diagram, rules exist for determining the appropriate linear model, ANOVA table, expected means squares, and F-tests in the case of balanced designs. This procedure has been implemented in LISP-STAT using a software representation of the experimental design. The user can interact with the Hasse diagram to add, change, or delete factors and see the effect on the proposed analysis. The system has potential uses in teaching and consulting.


Introduction
Hasse diagrams have been described previously for their usefulness in visualizing experimental designs and determining the correct model for orthogonal (or balanced), mixed effects designs (Taylor &Hilton, 1981, andLohr, 1995).They show the nesting relationships, as well as other information, about the factors in an experiment.This paper describes a Lisp-Stat system for visualizing experimental designs using the Hasse diagram.Given information about the factors in a design, the system will produce: • A Hasse diagram of the nesting relationships among the factors.
• The terms in an appropriate linear model.
• An outline of the ANOVA table with appropriate F-tests.
• Formulas for the expected mean square of each term in the model.
The system uses heuristic rules presented in Taylor & Hilton and the object-oriented and dynamic graphics programming features available in LISP-STAT (Tierney, 1990).The user is able to interact with the diagram to change factors and their settings and to see the effects of these changes on the model and the analysis.Section two describes response structures and their relationship with Hasse diagrams, also called structure diagrams.Section three summarizes factor sets, which are used to construct the expected mean squares, appropriate F tests, and the ANOVA table.Section four describes our system and the underlying software representation.We illustrate the system with several examples in section five.

Response Structures and Hasse Diagrams
Responses that are outcomes of a designed experiment can be classified by factors of the experiment.The factors may consist of experimental treatments, or may correspond to various spatial or temporal arrangements of the experimental units, such as plots and blocks.Levels of factors partition the set of responses into disjoint, nonempty subsets.Upper case letters denote factors and subscripts denote levels of factors.For example, let X = {A, B, C} be a set of factors of interest in an experiment.Then A 1 , B 3 , C j denote various levels of each of the factors.A combination of a set of factors is a set of responses formed by the intersection of individual levels of each factor.For example, x ijk = A i ∩B j ∩C k is a combination of X.The set of responses and a corresponding set of factors, X, are said to form a response structure.A response structure in which every possible combination of the set of factors is nonempty and all combinations of every subset of factors contain the same number of responses, is called a balanced complete response structure.
We use the following definition of nesting.Given two factors A and B of a response structure, if the partition of responses generated by B is a refinement of the partition given by A, then factor B is said to be nested in A. More formally, factor B is said to be nested in A if each level of B appears with one, and only one, level of A. Throckmorton (1961) shows that, by considering the nesting relationship among the factors as a partial ordering relation on the set of responses, a balanced complete response structure can be represented by a lattice.A lattice is a partially ordered set in which every pair of elements has a least upper bound and a greatest lower bound.It can be shown that the set of factors of a response structure and the nesting relationship satisfy this definition.
A lattice structure can be represented visually by a Hasse diagram, in which a node that covers other nodes is placed immediately above those nodes in the diagram and is connected to those nodes with line segments.Hasse diagrams are discussed extensively by Throckmorton (1961) and Kempthorne (1982).Thus balanced complete response structures can be represented by Hasse diagrams in which the nodes correspond to the factors and line segments denote nesting relationships.
In the Hasse diagram of Figure 1, u represents the grand mean and E represents the error term.All factors are nested in u, and E is nested in all other factors.In addition, C is nested in A. If two factors are not connected by an upward link, they are crossed.Thus, B is crossed with A and C. The number in parentheses after each factor is the range, or number of levels.For a nested factor, say C, this number indicates that C has three levels for each level of A. Finally, fixed factors are underlined while random factors are not.
The set of factors of the original response structure augmented by the interactions of crossed factors from the original response structure and u, also form a lattice, which is u(1) useful for determination of the corresponding linear model and associated computations as discussed in Taylor and Hilton (1981).The augmented lattice for the above example is given in Figure 2.
From Figure 2, it can be ascertained that the interaction AB is nested in u, and that the interaction BC is nested in AB.Carney (1967) established that each term of the augmented lattice identify "components" which correspond to "sources of variability" in an ANOVA table or "effects" in a linear model.Using conventional labelling, the responses in the response structure discussed above are y ijk with i, j, k denoting levels of factors A, B, and C respectively.The linear model corresponding to the above structure is thus where, for simplicity, the factor names are used to denote the effects, except for the BC interaction, which is the error term, jk(i) .Note that parenthesized subscripts denote levels of factors that next the factor which corresponds to the effect name.Thus the effect C k(i) should be read as "C nested in A."  Factors sets are defined in terms of the nesting relationships and factor types (fixed or random).They play a central role in determing the ANOVA table and expected mean squares, and are easily obtained with reference to the Hasse diagram.The set of all factors in an experimental design is called the design set (DS).An effect is any single factor or any combination of 2 or more crossed factors.Every effect defines a different partition of the design set.The breakdown of the design set into factor sets is shown in table 1.Note the following relationships among the factor sets:

Factor Sets
Two numerical quantities associated with each effect and required for the ANOVA table are obtained from the factor sets.First we define the range of a factor as its number of levels and the diminished range as the range minus one.The symbolic product of an effect is computed as the product of the diminished ranges of its live factors and the ranges of its dead factors.The symbolic product generates the degrees of freedom for the given effect.The complement product of an effect is the product of the diminished ranges of its complement factors and generates the expected mean square coefficient for the given effect.
The final ingredient is the notion of formal interaction.The formal interaction of two effects is found by first juxtaposing all factors in the effects and then removing duplicates and factors that nest any other factors.The result is always an allowable effect.The next section describes our Lisp-Stat system.

Lisp-Stat Implementation
The LISP-STAT environment provides an excellent platform for object-oriented programming and customized dynamic graphics.The symbolic processing power of LISP is also available.We make use of these features to manipulate factor sets and to allow the user to interact with the Hasse diagram.
Object-oriented programming involves the use of computing entities, called objects, that contain both data and the procedures for processing that data.The data for each object are stored in slots.Procecures are called by sending a message to an object to execute one of its methods.For example, reg-model is a Lisp-Stat regression-model object, and we could ask it to plot its residuals with the expression (send reg-model :plot-residuals) In the Lisp-Stat object system, there exist certain objects called prototypes.A prototype object contains the blueprint for creating new objects, called instances.Each instance has its own slots to hold data, but looks to its prototype for the code to execute methods.However, an instance may also have its own methods that either add to, or override, the prototype methods.Thus, code can be shared by many objects.In addition, prototypes may be arranged in an inheritance hierarchy, that allows prototypes to inherit, i.e. reuse, code from other prototypes.For more information on Lisp-Stat and its object system, see Tierney (1990).
Our system defines three prototype objects: balanced-anova-proto, factor--proto, and Hasse-diagram-proto.The first two prototypes inherit from the LISP-STAT root object *object*, and Hasse-diagram-proto inherits from the LISP-STAT prototype graph-window-proto.These are described in detail below, following the system overview.

System Overview
Balanced experimental designs are implemented using the prototype, balanced-anova--proto.It contains slots to hold data about a design and methods to process that data.The user begins by calling the function balanced-anova-model, for example, which returns a new instance of balanced-anova-proto to the variable ba.
This function also prompts the user to select a design file, which is a plain text file that described the factors in a design.Or, a default design file can be loaded automatically.The design file for the experiment shown in Figure 1 is: There is one line for each factor in the design.Each factor is represented as a list of four elements: the factor name (or letter designation), number of levels, type (either fixed or random) and a list of all factors in which the given factor is nested.An empty list, nil, in the fourth position indicates that the given factor is not nested in any other factors.Characters may be entered in upper-or lowercase; however, Lisp-Stat converts them to uppercase.The error term factor is required, and it must be nested in all of the other factors.
A new instance of factor-proto is created for each factor, and these objects are stored as a list in the balanced-anova object.Next, a list of all allowable effects in the model is computed and saved.The Hasse diagram is displayed, and a menu is installed that allows access to the Hasse diagram, ANOVA table, expected mean square formulas, and factor sets.The Hasse diagram has two modes of interactivity.First, the user can re-position nodes horizontally to improve the visual appearance of the diagram.Second, the user can change a factor's settings by shift-clicking on a node.A dialog window shows the current settings (name, range, type, and nested-in factors) and allows changes.The Hasse diagram is automatically updated when this information is changed and the user clicks the OK button.A factor can be deleted by checking the Delete button in the dialog window.A factor can be added to the design by clicking on the white space between nodes.The user may also load another design from the menu to replace the current design.

Balanced ANOVA prototype -Slots and primary methods
Balanced ANOVA objects have the following slots: • factors -list of factor objects • effects -list of allowable effects • menu -menu object • factor-names -list of factor names The following balanced-anova-proto methods correspond to items in the menu.Method names always begin with a colon (:) and are followed by an argument list, where () means that no arguments are required.
• :load-design () loads a design file.This method is run automatically by the function, balanced-anova-model.
• :draw-hasse () draws the Hasse diagram.Each node in the diagram corresponds to a factor in the design.The vertical positioning of the nodes is determined by the nesting relationships.The user is able to rearrange the nodes by dragging them horizontally.One special node is added to complete the diagram: the grand mean which has one level, is fixed, and nests all other factors.Its nesting relationship is added automatically and should not be included in the design file.
• :augmented-hasse draws the augmented Hasse diagram, which has a node for every allowable effect.
• :linear-model () writes the list of effects as a linear model.
• :show-table () displays the ANOVA table, which has columns for source of variation, degrees of freedom, and mean square values and F-tests.Each allowable effect produces a line in the ANOVA.The value for the degrees of freedom comes from the symbolic product, and the F-test formula is derived via the following procedure.Form two sets of effects, S e and S o , defined as All n-way, n = (0, 1, 2, . ..), formal interactions of factors in SRCF are computed at once using the :allowable-effects method, which takes the set, SRCF , and returns the list of effects, S e ∪ S o .Then the even-way and odd-way interactions are extracted depending on the number of factors in the effect (even or odd).
Finally, the numerator of the F-test is the sum of the mean squares of the effects in S e , and the denominator is similarly obtained from S o .The sets, S e and S o always have the same size, say m.If m = 1, the F-test is exact; otherwise, the ratio represents an approximate Satterthwaite test.
• :ems-list () displays formulas for the expected mean square of each effect in the model.Expected mean squares are computed by first forming the set S = {s|s is a formal interaction of LF with an m-way interaction of factors in RCF , m = (0, 1, 2, . ..)} This set contains the effects that appear in the expected mean square with coefficients given by the complement product.Thus for a given effect, Q, where k(s) is the complement product of the effect, s, and σ 2 s is a variance component if s is random, or a mean squared deviation from the treatment mean if s is fixed.An effect is random if any one of its live factors, LF , is random.
• :factor-sets () displays the important factor sets (SF , LF , DF , CF , RCF , and SRCF ) for a user-selected subset of effects.

Balanced ANOVA prototype -Other methods
The following balanced-anova-proto methods are used by the methods described above and are available for investigating the balanced-anova object.
• :factors (&optional factors) returns the list of factors stored in the factors slot.If an argument is supplied, it will become the new slot value.The argument should be a list whose items are instances of factor-proto (see section 4.4).
• :effects (&optional effects) returns the list of effects stored in the effects slot.If an argument is supplied, it will become the new slot value.This slot can be reset with the following expression: (send ba :effects (send ba :allowable-effects (send ba :factors))) • :allowable-effects (factor-list) computes all allowable effects that can be derived from the list of factors and their nesting relationships.An effect is allowable if no factor in the effect is nested in another factor in the effect, i.e., if all of the factors in the effect are crossed with each other.
• :complement-factors (effect) returns the set of complement factors for effect.
• :complement-prod (effect) returns the complement product of effect.
• :dead-factors (effect) returns the set of dead factors for effect.
• :effect-string (effect &key extended) returns a string that writes the effect in the usual notation, e.g.B*C. if :extended is t then the factors in which the effect is nested are included in parentheses, e.g.B*C(A).
• :F-test (this-effect) displays the F-test formula for this-effect.
• :gfi (effect-list effect) computes the generalized formal interaction of the effect with each item in effect-list and returns a list of the results.This method is used when computing the F-test and expected mean square formulas.
• :MS-string (effect &key expected maxlen) writes the effect name as a mean square name or expected mean square name (if :expected is t), e.g.MS-B*C or EMS-B*C.the argument maxlen can be used to control the width of the printed text.
• :random-CF (effect) returns the set of random complement factors for the effect.
• :simple-RCF (effect) returns the set of simple random complement factors for the effect.
• :symbolic-factors (effect) returns the set of symbolic factors for the effect.
• :symbolic-product (effect) returns the symbolic product of the effect.
• :write-ems (this-effect) displays the expected mean square formula for this-effect, in which a variance component is denoted by the effect name in parentheses, and a mean squared deviation from a treatment mean is denoted by the effect name in square brackets.For the example shown in Figure 1, since B is fixed, but C*B and E are random effects.

Factor prototype
The prototype, factor-proto, is used to create factor objects.Each factor object contains the following slots, which can be accessed and changed using a method that matches the name of the slot, e.g., :name.
• name -factor name, or letter designation.
• range -the number of levels in the factor.
• nested-in -list of factor objects in which the factor is nested.
• parents -list of factor objects that are direct parents of the factor.See Hasse--diagram-proto for more details.
• x -x-coordinate of the factor in Hasse diagram.Used by Hasse-diagram--proto.
• y -y-coordinate of the factor in the Hasse diagram.Used by Hasse-diagram--proto.
• depth -the depth, or level, of the factor in the Hasse diagram.The grand mean is level zero, so the total number of levels is the maximum depth plus 1.This is used by Hasse-diagram-proto to draw the Hasse diagram.
The only other method for factor-proto is :print which overrides the default method in the Lisp-Stat object, *object*.For example, a factor named, A, would be printed as, #<factor A>.

Hasse diagram prototype
The hasse-diagram prototype contains the methods for drawing and updating the Hasse diagram.When the :draw-hasse message is sent to a balanced-anova object, the following actions take place: • A new hasse-diagram instance is created.It receives the list of factors from the balanced-anova object and stores it in the slot, nodes.
• A root node is added to represent the grand mean.All other nodes are nested in this node.
• For each factor, the direct parents are computed and stored in the parents slot of the factor.
• For each factor, the depth is computed and stored in the depth slot of the factor.
The grand mean has depth zero; its children have depth one, and so on.
• An initial location, (x, y), is computed for each factor and stored in the x and y slots of the factor.
• The diagram is displayed and saved in the hasse-diagram slot of the balancedanova object.

Example 1:
The first example is a two-way ANOVA with fixed factors, A and B, which are crossed.The input file is specified as follows: The corresponding Hasse diagram is shown in Figure 3.
u(1) The output includes the model, the ANOVA table with appropriate F-tests, and the expected mean squares.Note that there are two levels for the error term, indicating two independent experimental units for each combination of A and B.
Expected Mean Squares: Note: (.) is a variance component.
[.] is a mean squared deviation from a treatment mean.

Example 2:
The next example corresponds to the Hasse diagram in Figure 1.There are two fixed factors, A and B, that are crossed, and a random factor, C that is nested in A. This diagram corresponds to that of a split-plot experiment where A is the whole-plot treatment, B is the sub-plot treatment, and C is the whole-plot experimental unit.The input file needed to specify this design is as follows: This Hasse diagram could also be obtained from the design in Example 1 by adding a random factor, C, that is nested in factor A. This is done using the dropdown menu system and selecting the Add a Factor ... option, as shown in Figure 4, with the options required to make this change.A similar dialog is displayed when one shift-clicks on a node in the diagram to change its settings.
The ANOVA table that corresponds to this Hasse diagram shows that the correct error term for A is MS C , and the correct error term for B and A*B is MS C * B .Note that when the error term has only one level (i.e., no replication at the finest factor partition), there is an effect with zero degrees of freedom shown in the ANOVA table and the expected mean squares.It is suppressed in the equation for the linear model.Note: (.) is a variance component.
[.] is a mean squared deviation from a treatment mean.

Example 3:
The last example is the 7-factor mixed effects design example from Taylor and Hilton.
In an industrial experiment three factories (F) were chosen at random to conduct a study of two kinds (K) of tool rests (R) and two angles (A) of edges for lathe tools (T).Each factory received four tools rests, two of each kind.In each factory three machinists (M) were assigned randomly to use each of the tool rests on four randomly setected lathes (L).Each factory was assigned 96 tools, with one third of the tools being of each angle.To control wear and assure uniformity of tool usage, each tool was used only with a specific lathe and a specific tool rest.The structure diagram used in the Taylor and Hilton paper for all calculations is shown below.
The input file needed to specify this design is as follows: u( 1)

Discussion
This paper has described a Lisp-Stat implementation of Hasse diagrams for balanced, mixed effects designs.It allows the user to describe an experimental design by listing the factors and the nesting relationships among the factors.It provides an interactive Hasse diagram that lets the user visualize even complex crossing and nesting relationships.From the diagram, the system determines the appropriate linear model, expected mean squares, and ANOVA table with F-tests for each of the effects.The user can interactively change the design and see the effects on the output.The Hasse diagram can be used to describe more general designs, but the calculations derived from it only apply to balanced designs.
The system can be used for teaching these design and analysis concepts.A thorough understanding of partial orderings is not required to understand Hasse diagrams.In fact, the Hasse diagram could help students understand nesting and crossing relationships, as well as derivations of appropriate F-tests and expected mean squares.
In addition to the use of Hasse diagrams as a pedagogical tool, Marasinghe and Darius (1990) and Lohr (1995) have pointed out a more proactive use as an interactive and expert aid for designing experiments.If it is possible to derive models and compute analyses of variance resulting from a modified structure instanteously, one would be able to determine and keep track of the effects of changes to, additions, or deletions of one or more nodes from an existing diagram.This ability to provide feedback to possible design modifications complements the process that naturally occurs when complex multifactor experiments with multiple levels of nesting and crossing are developed.
Another application of Hasse diagrams occurs when statistical consultants are called upon to analyze experiments they were not involved with in the planning stages.The familiar query-and-response session between a statistical consultant and an experimenter could lead to a formulation of an appropriate Hasse diagram, from which an acceptable analysis can be obtained.Lohr (1995), through the use of several examples, describes how a Hasse diagram may be constructed interactively using such a technique.
In each of the above cases, the statistician, can proceed by first determining the factors that are not nested in any other factor.These are at the top level of factors in the structure diagram.Then the factors that are nested in the factors in the top-level are determined and so on.

Software Availability
The program is available from the authors, along with several example design files and instructions for getting started.

Figure 4 :
Figure 4: Dialog for adding a factor

Table 1 :
Factor Sets.The partition becomes finer as one moves from left to right.