Gifi Methods for Optimal Scaling in R: The Package homals

20
Gifi Methods for Optimal Scaling in R: The Package homals Jan de Leeuw University of California, Los Angeles Patrick Mair WU Wirtschaftsuniversit¨ at Wien Abstract Homogeneity analysis combines the idea of maximizing the correlations between vari- ables of a multivariate data set with that of optimal scaling. In this article we present methodological and practical issues of the R package homals which performs homogeneity analysis and various extensions. By setting rank constraints nonlinear principal compo- nent analysis can be performed. The variables can be partitioned into sets such that homogeneity analysis is extended to nonlinear canonical correlation analysis or to predic- tive models which emulate discriminant analysis and regression models. For each model the scale level of the variables can be taken into account by setting level constraints. All algorithms allow for missing values. Keywords :˜Gifi methods, optimal scaling, homogeneity analysis, correspondence analysis, nonlinear principal component analysis, nonlinear canonical correlation analysis, homals, R. 1. Introduction In recent years correspondence analysis (CA) has become a popular descriptive statistical method to analyze categorical data (Benz´ ecri 1973; Greenacre 1984; Gifi 1990; Greenacre and Blasius 2006). Due to the fact that the visualization capabilities of statistical software have increased during this time, researchers of many areas apply CA and map objects and variables (and their respective categories) onto a common metric plane. Currently, R (R Development Core Team 2008) offers a variety of routines to compute CA and related models. An overview of functions and packages is given in Mair and Hatzinger (2007). The package ca (Nenadic and Greenacre 2006) is a comprehensive tool to perform simple and multiple CA. Various two- and three-dimensional plot options are provided. In this paper we present the R package homals, starting from the simple homogeneity analysis, which corresponds to a multiple CA, and providing several extensions. Gifi (1990) points out that homogeneity analysis can be used in a strict and a broad sense. In a strict sense homogeneity analysis is used for the analysis of strictly categorical data, with a particular loss function and a particular algorithm for finding the optimal solution. In a broad sense homogeneity analysis refers to a class of criteria for analyzing multivariate data in general, sharing the characteristic aim of optimizing the homogeneity of variables under various forms of manipulation and simplification (Gifi 1990, p. 81). This view of homogeneity analysis will be used in this article since homals allows for such general computations. Furthermore, the two-dimensional as well as three-dimensional plotting devices offered by R are used to develop

Transcript of Gifi Methods for Optimal Scaling in R: The Package homals

Page 1: Gifi Methods for Optimal Scaling in R: The Package homals

Gifi Methods for Optimal Scaling in R:

The Package homals

Jan de LeeuwUniversity of California, Los Angeles

Patrick MairWU Wirtschaftsuniversitat Wien

Abstract

Homogeneity analysis combines the idea of maximizing the correlations between vari-ables of a multivariate data set with that of optimal scaling. In this article we presentmethodological and practical issues of the R package homals which performs homogeneityanalysis and various extensions. By setting rank constraints nonlinear principal compo-nent analysis can be performed. The variables can be partitioned into sets such thathomogeneity analysis is extended to nonlinear canonical correlation analysis or to predic-tive models which emulate discriminant analysis and regression models. For each modelthe scale level of the variables can be taken into account by setting level constraints. Allalgorithms allow for missing values.

Keywords:˜Gifi methods, optimal scaling, homogeneity analysis, correspondence analysis,nonlinear principal component analysis, nonlinear canonical correlation analysis, homals, R.

1. Introduction

In recent years correspondence analysis (CA) has become a popular descriptive statisticalmethod to analyze categorical data (Benzecri 1973; Greenacre 1984; Gifi 1990; Greenacre andBlasius 2006). Due to the fact that the visualization capabilities of statistical software haveincreased during this time, researchers of many areas apply CA and map objects and variables(and their respective categories) onto a common metric plane.

Currently, R (R Development Core Team 2008) offers a variety of routines to compute CAand related models. An overview of functions and packages is given in Mair and Hatzinger(2007). The package ca (Nenadic and Greenacre 2006) is a comprehensive tool to performsimple and multiple CA. Various two- and three-dimensional plot options are provided.

In this paper we present the R package homals, starting from the simple homogeneity analysis,which corresponds to a multiple CA, and providing several extensions. Gifi (1990) pointsout that homogeneity analysis can be used in a strict and a broad sense. In a strict sensehomogeneity analysis is used for the analysis of strictly categorical data, with a particularloss function and a particular algorithm for finding the optimal solution. In a broad sensehomogeneity analysis refers to a class of criteria for analyzing multivariate data in general,sharing the characteristic aim of optimizing the homogeneity of variables under various formsof manipulation and simplification (Gifi 1990, p. 81). This view of homogeneity analysis willbe used in this article since homals allows for such general computations. Furthermore, thetwo-dimensional as well as three-dimensional plotting devices offered by R are used to develop

Page 2: Gifi Methods for Optimal Scaling in R: The Package homals

2 Homals in R

a variety of customizable visualization techniques. More detailed methodological descriptionscan be found in Gifi (1990) and some of them are revisited in Michailidis and de˜Leeuw(1998).

2. Homogeneity analysis

In this section we will focus on the underlying methodological aspects of homals. Startingwith the formulation of the loss function, the classical alternating least squares algorithm ispresented in brief and the relation to CA is shown. Based on simple homogeneity analysiswe elaborate various extensions such as nonlinear canonical analysis and nonlinear principalcomponent analysis. A less formal introduction to Gifi methods can be found in Mair and deLeeuw (2009).

2.1. Establishing the loss function

Homogeneity analysis is based on the criterion of minimizing the departure from homogeneity.This departure is measured by a loss function. To write the corresponding basic equations thefollowing definitions are needed. For i = 1, . . . , n objects, data on m (categorical) variablesare collected where each of the j = 1, . . . ,m variable takes on kj different values (their levelsor categories). We code them using n × kj binary indicator matrices Gj , i.e., a matrix ofdummy variables for each variable. The whole set of indicator matrices can be collected in ablock matrix

G∆=[G1

... G2... · · ·

... Gm

]. (1)

In this paper we derive the loss function including the option for missing values. For a simpler(i.e. no missings) introduction the reader is referred to Michailidis and de˜Leeuw (1998, p.307–314). In the indicator matrix missing observations are coded as complete zero rows; ifobject i is missing on variable j, then row i of Gj is 0. Otherwise the row sum becomes 1 sincethe category entries are disjoint. This corresponds to the first missing option presented in Gifi(missing data passive 1990, p. 74). Other possibilities would be to add an additional columnto the indicator matrix for each variable with missing data or to add as many additionalcolumns as there are missing data for the j-th variable. However, our approach is to definethe binary diagonal matrix Mj if dimension n× n for each variable j. The diagonal element(i, i) is equal to 0 if object i has a missing value on variable j and equal to 1 otherwise. Basedon Mj we can define M? as the sum of the Mj ’s and M• as their average.

For convenience we introduce

Dj∆=G′jMjGj = G′jGj , (2)

as the kj×kj diagonal matrix with the (marginal) frequencies of variable j in its main diagonal.

Now let X be the unknown n × p matrix containing the coordinates (object scores) of theobject projections into Rp. Furthermore, let Yj be the unknown kj × p matrix containing thecoordinates of the category projections into the same p-dimensional space (category quantifi-cations). The problem of finding these solutions can be formulated by means of the followingloss function to be minimized:

σ(X;Y1, . . . , Ym)∆=

m∑j=1

tr(X −GjYj)′Mj(X −GjYj) (3)

Page 3: Gifi Methods for Optimal Scaling in R: The Package homals

Jan de Leeuw, Patrick Mair 3

We use the normalization u′M•X = 0 and X ′M•X = I in order to avoid the trivial solutionX = 0 and Yj = 0. The first restriction centers the graph plot (see Section 4) around theorigin whereas the second restriction makes the columns of the object score matrix orthogonal.Multiplying the scores by

√n/m gives a mean of 0 and a variance of 1 (i.e., they are z-scores).

Note that from an analytical point of view the loss function represents the sum-of-squaresof (X − GjYj) which obviously involves the object scores and the category quantifications.Thus, we minimize simultaneously over X and Yj . We give a graphical interpretation of theloss function in the following section.

2.2. Geometry of the loss function

In the homals package we use homogeneity analysis as a graphical method to explore multi-variate data sets. The joint plot mapping object scores and the category quantifications in ajoint space, can be considered as the classical or standard homals plot. The category pointsare the centers of gravity of the object points that share the same category. The larger thespread between category points the better a variable discriminates and thus the smaller thecontribution to the loss. The closeness of two objects in the plot is related to the similarityof their response patterns. A “perfect” solution, i.e., without any loss at all, would imply thatall object points coincide with their category points.

Moreover, we can think of G as the adjacency matrix of a bipartite graph in which the nobjects and the kj categories (j = 1, . . . ,m) are the vertices. In the corresponding graphplot an object and a category are connected by an edge if the object is in the correspondingcategory. The loss in (3) pertains to the sum of squares of the line lengths in the graph plot.Producing a star plot, i.e., connecting the object scores with their category centroid, the losscorresponds to the sum over variables of the sum of squared line lengths. More detailed plotdescriptions are given in Section 4.

2.3. Minimizing the loss function

Typically, the minimization problem is solved by the iterative alternating least squares algo-rithm (ALS; sometimes quoted as reciprocal averaging algorithm). At iteration t = 0 we startwith arbitrary object scores X(0). Each iteration t consists of three steps:

1. Update category quantifications: Y(t)j = D−1

j G′jX(t) for j = 1, . . . ,m

2. Update object scores: X(t) = M−1?

∑mj=1GjY

(t)j

3. Normalization: X(t+1) = M− 1

2? orth(M

− 12

? X(t))

Note that matrix multiplications using indicator matrices can be implemented efficiently ascumulating the sums of rows over X and Y .

Here orth is some technique which computes an orthonormal basis for the column spaceof a matrix. We can use QR decomposition, modified Gram-Schmidt, or the singular valuedecomposition (SVD). In the homals package the left singular vectors of X(t), here denotedas lsvec, are used.

To simplify, let Pj denote the orthogonal projector on the subspace spanned by the columns

Page 4: Gifi Methods for Optimal Scaling in R: The Package homals

4 Homals in R

of Gj , i.e., Pj = GjD−1j G′j . Correspondingly, the sum over the m projectors is

P? =

m∑j=1

Pj =

m∑j=1

GjD−1j G′j . (4)

Again, P• denotes the average. By means of the lsvec notation and including P• we candescribe a complete iteration step as

X(t+1) = lsvec(X(t)) = lsvec(M−1• P•X

(t)). (5)

In each iteration t we compute the value of the loss function to monitor convergence. Notethat Formula (5) is not suitable for computation, because it replaces computation with sparseindicator matrices by computations with a dense average projector.

Computing the homals solution in this way is the same as performing a CA on G. Usually,multiple CA solves the generalized eigenproblem for the Burt matrix C = G′G and its diagonalD (Greenacre 1984; Greenacre and Blasius 2006). Thus, we can put the problem in Equation3 into a SVD context (de Leeuw, Michailidis, and Wang 1999). Using the block matrixnotation, we have to solve the generalized singular value problem of the form

GY = M?XΛ, (6)

G′X = DY Λ, (7)

or equivalently one of the two generalized eigenvalue problems

GD−1G′X = M?XΛ2, (8)

G′M−1? GY = DY Λ2. (9)

Here the eigenvalues Λ2 are the ratios along each dimension of the average between-categoryvariance and the average total variance. Also X ′PjX is the between-category dispersion forvariable j. Further elaborations can be found in Michailidis and de˜Leeuw (1998).

Compared to the classical SVD approach, the ALS algorithm only computes the first p di-mensions of the solution. This leads to an increase in computational efficiency. Moreover, bycapitalizing on sparseness of G, the homals package is able to handle large data sets.

The goodness-of-fit of a solution can be examined by means of a screeplot of the eigenval-ues. The contribution of each variable to the final solution can be examined by means ofdiscrimination measures defined by ||GjYj ||2 /n (see Meulman 1996).

3. Extensions of homogeneity analysis

Gifi (1990) provides various extensions of homogeneity analysis and elaborates connectionsto other multivariate methods. The package homals allows for imposing restrictions on thevariable ranks and levels as well as defining sets of variables. These options offer a wide spec-trum of additional possibilities for multivariate data analysis beyond classical homogeneityanalysis (cf. broad sense view in the Introduction).

3.1. Nonlinear principal component analysis

Having a n×m data matrix with metric variables, principal components analysis (PCA) is acommon technique to reduce the dimensionality of the data set, i.e., to project the variables

Page 5: Gifi Methods for Optimal Scaling in R: The Package homals

Jan de Leeuw, Patrick Mair 5

into a subspace Rp where p � m. The Eckart-Young theorem states that this classical formof linear PCA can be formulated by means of a loss function. Its minimization leads to an× p matrix of component scores and an m× p matrix of component loadings.

However, having nonmetric variables, nonlinear PCA (NLPCA) can be used. The term “non-linear” pertains to nonlinear transformations of the observed variables (de Leeuw 2006). InGifi terminology, NLPCA can be defined as homogeneity analysis with restrictions on thequantification matrix Yj . Let us denote rj ≤ p as the parameter for the imposed restrictionon variable j. If no restrictions are imposed, as e.g. for a simple homals solution, rj = kj − 1iff kj ≤ p, and rj = p otherwise.

We start our explanations with the simple case for rj = 1 for all j. In this case we say thatall variables are single and the rank restrictions are imposed by

Yj = zja′j , (10)

where zj is a vector of length kj with category quantifications and aj a vector of length pwith weights. Thus, each quantification matrix is restricted to rank 1, which allows for theexistence of object scores with a single category quantification.

3.2. Multiple quantifications

It is not necessarily needed that we restrict the rank of the score matrix to 1. Our homalsimplementation allows for multiple rank restrictions. We can simply extend Equation 10 tothe general case

Yj = ZjA′j (11)

where again 1 ≤ rj ≤ min (kj − 1, p), Zj is kj × rj and Aj is p× rj . We require, without lossof generality, that Z ′jDjZj = I. Thus, we have the situation of multiple quantifications whichimplies imposing an additional constraint each time PCA is carried out.

To establish the loss function for the rank constrained version we write r? for the sum of therj and r• for their average. The block matrix G of dummy variables now becomes

Q∆=[G1Z1

... G2Z2... · · ·

... GmZm

]. (12)

Gathering the Aj ’s in a block matrix as well, the p× r? matrix

A∆=[A1

... A2... · · ·

... Am

](13)

results. Then, Equation 3 becomes

σ(X;Z;A) =

m∑j=1

tr (X −GjZjA′j)′Mj(X −GjZjA

′j) =

= mtr X ′M?X − 2tr X ′QA+ tr A′A =

= mp+ tr (Q−XA)′(Q−XA)− tr Q′Q =

= tr(Q−XA)′(Q−XA) +m(p− r•) (14)

This shows that σ(X;Y1, · · · , Ym) ≥ m(p− r•) and the loss is equal to this lower bound if wecan choose the Zj such that Q is of rank p. In fact, by minimizing (14) over X and A we see

Page 6: Gifi Methods for Optimal Scaling in R: The Package homals

6 Homals in R

that

σ(Z)∆= min

X,Aσ(X;Z;A) =

r?∑s=p+1

λ2s(Z) +m(p− r•), (15)

where the λs are the ordered singular values. A corresponding example in terms of a lossplotis given in Section 4.

3.3. Level constraints: Optimal scaling

From a general point of view, optimal scaling attempts to do two things simultaneously:The transformation of the data by a transformation appropriate for the scale level (i.e. levelconstraints), and the fit of a model to the transformed data to account for the data. Thusit is a simultaneous process of data transformation and data representation (Takane 2005).In this paper we will take into account the scale level of the variables in terms of restrictionswithin Zj . To do this, the starting point is to split up Equation 14 into two separate terms.Using Yj = D−1

j G′jX this leads to∑mj=1 tr(X −GjYj)

′Mj(X −GjYj)

=∑m

j=1 tr(X −Gj(Yj + (Yj − Yj)))′Mj(X −Gj(Yj + (Yj − Yj)))

=∑m

j=1 tr(X −Gj Yj)′Mj(X −Gj Yj) +

∑mj=1 tr(Yj − Yj)′Dj(Yj − Yj). (16)

Obviously, the rank restrictions Yj = ZjA′j affect only the second term and hence, we will

proceed on our explanations by regarding this particular term only, i.e.,

σ(Z;A) =m∑j=1

tr(ZjA′j − Yj)′Dj(ZjA

′j − Yj). (17)

Now, level constraints for nominal, ordinal, polynomial, and numerical variables can be im-posed on Zj in the following manner. For nominal variables, all columns in Zj are unrestricted.Equation 17 is minimized under the conditions u′DjZj = 0 and Z ′jDjZj = I. The stationaryequations are

Aj = Y ′jDjZj , (18a)

YjAj = ZjW + uh′, (18b)

with W as a symmetric matrix of Langrange multipliers. Solving, we find

h =1

u′DjuA′jY

′jDju = 0, (19)

and thus, letting Zj∆=D

1/2j Zj and Y j

∆=D

1/2j Yj , it follows that

Y jY′jZj = ZjW. (20)

If Y j = KΛL′ is the SVD of Y j , then we see that Zj = KrO with O as an arbitrary rotationmatrix and Kr as the singular vectors corresponding with the r largest singular values. Thus,

Zj = D−1/2j KrO, and Aj = Y

′jZj = LrΛrO. Moreover, ZjA

′j = D

−1/2j KrΛrL

′r.

Page 7: Gifi Methods for Optimal Scaling in R: The Package homals

Jan de Leeuw, Patrick Mair 7

Having ordinal variables, the first column of Zj is constrained to be either increasing ordecreasing, the rest is free. Again (17) has to be minimized under the condition Z ′jDjZj = I(and optionally additional conditions on Zj). If we minimize over Aj , we can also solve theproblem tr(Z ′jDjYjY

′jDjZj) with Z ′jDjZj = I.

For polynomial constraints the matrix Zj are the first rj orthogonal polynomials. Thus allp columns of Yj are polynomials of degree rj . In the case of numerical variables, the firstcolumn in Zj denoted by zj0 is fixed and linear with the category numbers, the rest is free.Hence, the loss function in (17) changes to

σ(Z,A) =m∑j=1

tr(ZjA′j + zj0a

′j0 − Yj)′Dj(ZjA

′j + zj0a

′j0 − Yj). (21)

Since column zj0 is fixed, Zj is a kj × (rj − 1) matrix and Aj , with aj0 as the first column, isp× (rj − 1). In order to minimize (21), z′j0DjZj = 0 is required as minimization condition.

Note that level constraints can be imposed additionally to rank constraints. If the data sethas variables with different scale levels, the homals package allows for setting level constraintsfor each variable j separately. Unlike in Gifi (1990) and Michailidis and de˜Leeuw (1998) itis not necessary to have rank 1 restrictions in order to allow for different scaling levels. Ourimplementation allows for multiple ordinal, multiple numerical etc. level constraints.

3.4. Nonlinear canonical correlation analysis

In Gifi terminology, nonlinear canonical correlation analysis (NLCCA) is called “OVERALS”(van der Burg, de Leeuw, and Verdegaal 1988; van der Burg, de Leeuw, and Dijksterhuis1994). This is due to the fact that it has most of the other Gifi-models as special cases. Inthis section the relation to homogeneity analysis is shown. The homals package allows for thedefinition of sets of variables and thus, for the computation NLCCA between g = 1, . . . ,Ksets of variables.

Recall that the aim of homogeneity analysis is to find p orthogonal vectors in m indicatormatrices Gj . This approach can be extended in order to compute p orthogonal vectors inK general matrices Gv, each of dimension n × mv where mv is the number of variables(j = 1, . . . ,mv) in set v. Thus,

Gv∆=[Gv1

... Gv2

... · · ·... Gvmv

]. (22)

The loss function can be stated as

σ(X;Y1, . . . , YK)∆=

1

K

K∑v=1

tr

X − mv∑j=1

GvjYvj

′Mv

X − mv∑j=1

GvjYvj

. (23)

X is the n×p matrix with object scores, Gvj is n×kj , and Yvj is the kj×p matrix containingthe coordinates. Missing values are taken into account in Mv which is the element-wiseminimum of the Mj in set v. The normalization conditions are XM•X = I and u′M•X = 0where M• is the average of Mv.

Since NLPCA can be considered as special case of NLCCA, i.e., for K = m, all the additionalrestrictions for different scaling levels can straightforwardly be applied for NLCCA. Unlike

Page 8: Gifi Methods for Optimal Scaling in R: The Package homals

8 Homals in R

classical canonical correlation analysis, NLCCA is not restricted to two sets of variables butallows for the definition of an arbitrary number of sets. Furthermore, if the sets are treatedin an asymmetric manner predictive models such as regression analysis and discriminantanalysis can be emulated. For v = 1, 2 sets this implies that G1 is n× 1 and G2 is n×m− 1.Corresponding examples will be given in Section 4.2.

3.5. Cone restricted SVD

In this final methodological section we show how the loss functions of these models can besolved in terms of cone restricted SVD. All the transformations discussed above are projectionson some convex cone Kj . For the sake of simplicity we drop the j and v indexes and we lookonly at the second term of the partitioned loss function (see Equation 17), i.e.,

σ(Z,A) = tr(ZA′ − Y )′D(ZA′ − Y ), (24)

over Z and A, where Y is k × p, Z is k × r, and A is p × r. Moreover the first column z0

of Z is restricted by z0 ∈ K, with K as a convex cone. Z should also satisfy the commonnormalization conditions u′DZ = 0 and Z ′DZ = I.

The basic idea of the algorithm is to apply alternating least squares with rescaling. Thuswe alternate minimizing over Z for fixed A and over A for fixed Z. The “non-standard”part of the algorithm is that we do not impose the normalization conditions if we minimizeover Z. We show below that we can still produce a sequence of normalized solutions with anon-increasing sequence of loss function values.

Suppose (Z, A) is our current best solution. To improve it we first minimize over the non-normalized Z, satisfying the cone constraint, and keeping A fixed at A. This gives Z and acorresponding loss function value σ(Z, A). Clearly,

σ(Z, A) ≤ σ(Z, A), (25)

but Z is not normalized. Now update Z to Z+ using the weighted Gram-Schmidt solutionZ = Z+S for Z where S is the Gram-Schmidt triangular matrix. The first column z0 of Zsatisfies the cone constraint, and because of the nature of Gram-Schmidt, so does the firstcolumn of Z+. Observe that it is quite possible that

σ(Z+, A) > σ(Z, A). (26)

This seems to invalidate the usual convergence proof, which is based on a non-increasingsequence of loss function values. But now also adjust A to A = A(S−1)′. Then ZA′ = Z+A

′,

and thus

σ(Z, A) = σ(Z+, A). (27)

Finally compute A+ by minimizing σ(Z+, A) over A. Since σ(Z+, A+) ≤ σ(Z+, A) we havethe chain

σ(Z+, A+) ≤ σ(Z+, A) = σ(Z, A) ≤ σ(Z, A). (28)

In any iteration the loss function does not increase. In actual computation, it is not necessaryto compute A, and thus it also is not necessary to compute the Gram-Schmidt triangularmatrix S.

Page 9: Gifi Methods for Optimal Scaling in R: The Package homals

Jan de Leeuw, Patrick Mair 9

4. The R package homals

At this point we show how the models described in the sections above can be computed usingthe package homals in R (R Development Core Team 2008) available on CRAN.

The core function of the package for the computation of the methodology above is homals().The extended models can be computed by setting corresponding arguments: The rank argu-ment (integer value) allows for the calculation of rank-restricted nonlinear PCA. The level

argument (strings) allows to set different scale levels. By default the level is set to nominal.Finally, the sets argument allows for partitioning the variables into two or more sets in orderto perform nonlinear CCA. Examples can be found in the corresponding help files.

As a result, an object of class "homals" is created and the following methods are provided:print, summary, plot, plot3d, scatterplot3d and predict. The predict method works asfollows. Given a homals solution we can reconstruct the indicator matrix by assigning eachobject to the closest category point of the variable. We can then find out how well we havereconstructed the original data. For variables with rank restrictions we first have to projectthe objects on the hyperplane spanned by the category quantifications, and then computedistances in that plane. In any case we can make a square table of observed versus predictedfor each variable, showing misclassification.

The package offers a wide variety of plots; some of them are discussed in Michailidis andde˜Leeuw (1998) and Michailidis and de Leeuw (2001). In the plot method the user can spec-ify the type of plot through the argument plot.type. For some plot types three-dimensionalversions are provided in plot3d (dynamic) and plot3dstatic:

� Object plot ("objplot"): Plots the scores of the objects (rows in data set) on two orthree dimensions.

� Category plot ("catplot"): Plots the rank-restricted category quantifications for eachvariable separately. Three-dimensional plots are available.

� Voronoi plot ("vorplot"): Produces a category plot with Voronoi regions.

� Joint plot ("jointplot"): The object scores and category quantifications are mappedin the same (two- or three-dimensional) device.

� Graph plot ("graphplot"): Basically, a joint plot is produced with additional connec-tions between the objects and the corresponding response categories.

� Hull plot ("hullplot"): For a particular variable the object scores are mapped ontotwo dimensions. The convex hulls around the object scores are drawn with respect toeach response category of this variable.

� Label plot ("labplot"): Similar to object plot, the object scores are plotted but foreach variable separately with the corresponding category labels. A three-dimensionalversion is provided.

� Span plot ("spanplot"): Like label plot, it maps the object scores for each variable andit connects them by the shortest path within each response category.

� Star plot ("starplot"): Again, the object scores are mapped on two or three dimen-sions. In addition, these points are connected with the category centroid.

Page 10: Gifi Methods for Optimal Scaling in R: The Package homals

10 Homals in R

� Loss plot ("lossplot"): Plots the rank-restricted category quantifications against theunrestricted for each variable separately.

� Projection plot ("prjplot"): For variables of rank 1 the object scores (two-dimensional)are projected onto the orthogonal lines determined by the rank restricted categoryquantifications.

� Vector plot ("vecplot"): For variables of rank 1 the object scores (two-dimensional) areprojected onto a straight line determined by the rank restricted category quantifications.

� Transformation plot ("trfplot"): Plots variable-wise the original (categorical) scaleagainst the transformed (metric) scale Zj for each solution.

� Loadings plot ("loadplot"): Plots the loadings aj and connects them with the origin.Note that if rj > 1 only the first solution is taken.

� Scree plot ("screeplot"): Produces a scree plot based on the eigenvalues.

� Discrimination measures ("dmplot"): Plots the discrimination measures for each vari-able.

4.1. Simple homogeneity analysis

The first example is a simple (i.e., no level or rank restrictions, no sets defined) three-dimensional homogeneity analysis for the senate data set (ADA 2002). The data consists of2001 senate votes on 20 issues selected by Americans for Democratic Action. The votes se-lected cover a full spectrum of domestic, foreign, economic, military, environmental and socialissues. We tried to select votes which display sharp liberal/conservative contrasts. As a con-sequence, Democrat candidates have many more “yes” responses than Republican candidates.Due to non-responses we have several missings which are coded as NA. A full description of theitems can be found in the corresponding package help file. The first column of the data set(i.e., the variable “Party” containing 50 Republicans vs. 49 Democrats and 1 Independent) isinactive and will be used for validation.

> library("homals")

> data("senate")

> res <- homals(senate, active = c(FALSE, rep(TRUE, 20)), ndim = 3)

> plot3d(res, plot.type = "objplot", sphere = FALSE, bgpng = NULL)

> plot(res, plot.type = "spanplot", plot.dim = c(1, 2), var.subset = 1,

+ xlim = c(-2, 3), ylim = c(-2, 3), asp = 1)

> plot(res, plot.type = "spanplot", plot.dim = c(1, 3), var.subset = 1,

+ xlim = c(-2, 3), ylim = c(-2, 3), asp = 1)

> plot(res, plot.type = "spanplot", plot.dim = c(2, 3), var.subset = 1,

+ xlim = c(-2, 3), ylim = c(-2, 3), asp = 1)

> par(mfrow = c(1, 1))

> plot3dstatic(res, plot.type = "loadplot")

Page 11: Gifi Methods for Optimal Scaling in R: The Package homals

Jan de Leeuw, Patrick Mair 11

●●

●●

●●●

●●

●●

●●●●

●●

●●

●●●●

●●

●●

●●

● ●

●●●

●●

●●

−2 −1 0 1 2 3

−2

−1

01

23

Span plot for Party

Dimension 1

Dim

ensi

on 2

Category (D)Category (I)Category (R)

Category (D)Category (I)Category (R)

Category (D)Category (I)Category (R)

●●

●●

● ●

●●

●●●

●●

●●

●●●●

●●

● ●

●●

●●

●●●

●●

●●

●●

●●

−2 −1 0 1 2 3

−2

−1

01

23

Span plot for Party

Dimension 1

Dim

ensi

on 3

Category (D)Category (I)Category (R)

Category (D)Category (I)Category (R)

Category (D)Category (I)Category (R)

●●

●●

●●

●●

●●●

●●

●●

●●●●

● ●

● ●

●●

●●

●●●

●●

●●

● ●

●●

−2 −1 0 1 2 3

−2

−1

01

23

Span plot for Party

Dimension 2

Dim

ensi

on 3

Category (D)Category (I)Category (R)

Category (D)Category (I)Category (R)

Category (D)Category (I)Category (R)

Figure 1: 3D Object Plot and Span Plots for Senate Dataset

Figure 1 shows four branches (or clusters) of senators which we will denote by north, south,west and east. The west and the north branches are composed by Republicans, the east andsouth branches by Democrats. Note that the 3D-plot is rotated in a way that Dimension 3 ishorizontally aligned, Dimension 2 is vertically aligned, and Dimension 1 is the one aligned fromfront to back. The two-dimensional slices show that Dimension 1 vs. 2 does not distinguishbetween Democrats and Republicans. If Dimension 3 is involved, as in the two bottom plotsin Figure 1, the separation between Democrats and Republicans is obvious. To distinguishwithin north-west and south-east, respectively, Item 19 has to be taken into account:

V19: S 1438. Military Base Closures. Warner (R-VA) motion to authorize an additionalround of U.S. military base realignment and closures in 2003. A “yes” vote is a +.

Republicans belonging to the north branch as well as Democrats belonging to the east branchgave a “yes” vote. South-Wing Democrats and West-Wing Republicans voted with “no”. It

Page 12: Gifi Methods for Optimal Scaling in R: The Package homals

12 Homals in R

is well known that the response on this item mainly depends on whether there is a militarybase in the senator’s district or not; those senators who have a military base in their districtdo not want to close it since such a base provides working places and is an important incomesource for the district. Hence, this is the determining factor and not the party affiliation ofthe senator. This result is underpinned by Figure 2 where Item 19 is clearly separated fromthe remaining items.

Loadings plot

−4 −2 0 2 4 6 8

−10

−5

0 5

10

−8

−6

−4

−2

0

2

4

6

Dimension 1

Dim

ensi

on 2

Dim

ensi

on 3

●●●

●●●

●●

●●

● Party

V19

Figure 2: Loadings Plot for Senate Dataset

Given a (multiple) homals solution, we can reconstruct the indicator matrix by assigning eachobject to the closest points of the variable.

> p.res <- predict(res)

> p.res$cl.table$Party

pre

obs (D) (I) (R)

(D) 49 1 0

(I) 0 1 0

(R) 0 9 40

From the classification table we see that 91% of the party affiliations are correctly classified.Note that in the case of such a simple homals solution it can happen that a lower dimensionalsolution results in a better classification rate than a higher dimensional. The reason is thatin simple homals the classification rate is not the criterion to be optimized.

4.2. Predictive models and canonical correlation

Page 13: Gifi Methods for Optimal Scaling in R: The Package homals

Jan de Leeuw, Patrick Mair 13

The sets argument allows for partitioning the variables into sets in order to emulate canonicalcorrelation analysis and predictive models. As outlined above, if the variables are partitionedinto asymmetric sets of one variable vs. the others, we can put this type of homals model intoa predictive modeling context. If not, the interpretation in terms of canonical correlation ismore appropriate.

−2 0 2 4 6

−4

−2

02

Voronoi plot for advice

Dimension 1

Dim

ensi

on 2

Man

Man

Man

Man

ManMan

Gen

Ext

Man

Gen

Man ManManManMan

Gen

ManMan ManManMan

ManMan

ExtMan

Man

Man

Man

Gen

Man

Gen

Man

GenGen

Grls

Gen

Grls

Gen

Man

GenGenGen

UniUni

GenGen

UniUni

Gen

Man

Man

Uni

Man

Gen

Man

Man

Uni

Uni

Gen

Gen

ManGen

Man

Grls

Gen

GrlsGrls

Man

Man

Gen

ManMan

GenGen

Man

Man

GenGen

Man

Gen

Uni

GenGen

Gen

Uni

Gen

GenGen

Man

Uni

ManMan

GenGen

UniUni

Grls

Ext

Uni Uni

Ext

GenGen

Uni

Gen

Uni

Uni

Gen

Gen

Gen

Uni

Gen

Gen

GenMan

Uni Uni

AgrGen

GenGen

Man

Man

Ext

Man

Gen

Gen

Uni

Uni

GenGen

GenGen

Gen

ManManMan

GenMan Ext

Uni

Man

UniGrls

GenGen

Gen

Man

GenGen

Man

GenGen

Man

Uni

Man

AgrGen

Gen

Man

ManManManManManMan

Ext

Ext

ManMan

Gen

ExtExt

ManMan

ManMan

Ext

Gen

ManManMan

ExtExt

Man

Man

Gen

ManManExt

Gen

GenGen

ManMan

ExtExt

Gen

Man Ext

GenGenGen

ManManManMan

Grls

Man

Gen

Gen

ExtMan

Gen

GenGen

Man

Gen

Ext

Uni

Man

Gen

Uni

GenMan

ManManMan

Man

Gen

Ext

Uni

Ext

ManManMan

Man

Uni

Man

GenGenGenMan

Uni

Gen

Ext

Man

Gen

Man Man

Uni

Man

Gen

Man

Uni

Gen

ManManMan

Man

Uni

Gen

Uni

ExtExt Ext

Gen

Man

Ext

GenGenGen

Man

Uni

Gen

GenGen

ManMan

Gen

Gen

Gen

Man

GenGen

ManMan

Uni

Gen

Man

Gen

Man

Uni

Gen

Man

Man

ManManMan

ExtManManManMan

Man

Uni

Man

Man

Man

Man

Uni

Ext

Agr

ExtMan

Man

Man

Man

Man

Gen

Uni

Gen

Uni

Man

Man

GenGen

Uni

Gen

GenGen

Man

Gen

Man

Gen

Man

GenGen

Gen

Man Man

Gen

ManMan

GenUni

Gen

GenUni

Uni

Uni

Man

GenGenGen

Gen

Gen

Uni

Man Ext

ManMan

GenUni

Man

Gen

ManMan

Uni

Ext

Man

Gen

Ext

Man

Ext

Gen

Man

Gen

ManMan

Man

Gen

Man

ManManMan

Gen

Ext

Man

ExtExtMan

Gen

Man

Gen

ManManManManMan

GenGen

Man

Ext

Gen

Gen

Gen

Man

Ext

ManManManExt

ManMan

Man

Gen

ManManMan

Gen

ExtExt

Man

ManManMan

Man

GenGen

Gen

ExtMan

Gen

Gen

Gen

Man

Man

Man

Gen

Gen

Man

Uni

Ext

Uni

Man

Gen

Man

Gen

ManExtMan

GenGen

Man

Ext

GenGen

Ext

ManMan

Ext

ManManMan

Man

GenGen

Uni

Gen

Ext

Man

Man

Man

Gen

Gen

Uni

ManManMan

Uni

Gen Agr

ManMan

Gen

Man

Man

Gen

Gen

Man

Man

ManExt

GenGen

Agr

Man

Gen

Ext

ManMan

Uni

Man None

Gen

Man

GenGenGen

None

Man

GenGen

ManManExt

Gen

ManMan

Gen

Man

Gen

Uni

Ext

Gen

Gen

Gen

ManMan

Uni

GenGen

Uni

GenGenGen

UniUni

Ext

GenManGen

Man

GenGen

Man

ExtExt

Man

Uni

None

ManManMan

Man

Gen

Man

Uni

Man

Gen

Gen

Man

Uni

ExtExt

Man

ManGen

Man

Man

Ext

Man

Uni

Gen

Man

Ext

Man

UniUni

UniGen

Gen

UniUni

Man

Gen

Uni

Gen

Uni

Gen

Man

Man

Uni

ManGen

Gen

Gen

Uni

Gen

GenGen

ManMan

Uni

Gen

Uni

Gen

Gen

Gen

Man

Uni

Gen

Ext

Gen

GenGen

GenGen

Uni

Gen

Gen

UniUniUni

Gen

Man

Gen

Man

Gen

UniUni

ManGen

Uni

GenGenGen

Uni

Uni

GenGen

ManMan

Uni

Man

ExtExt

Uni

Ext

Uni

Grls

Man

Uni

Gen

Uni

ExtExt

Gen

Ext

GenGen

Ext

Gen

Gen

Ext

Man

Uni

GenMan

Uni

Uni

Ext

GenGen

Ext

Gen

UniUni

Gen

Uni

Ext

Man

Grls Gen

Gen

Uni

Gen

Gen

GenGrlsGrls

Uni

Gen

Uni

Man

Gen

Uni

ManMan

Man

GenGen

Ext

ExtMan

Gen

Gen

Uni

ManExt

Ext

Uni

Ext

Gen

ManMan

Man

GenManExt

ManMan

Ext

Gen

ExtMan

Uni

Man

ManExtExt

ManManManMan

Man

Gen

Man

ManMan

Man

Gen

ManMan

Gen

Man

GenGenManGen

ManManMan

Gen

Uni

Gen

Ext

Gen

Ext

Gen

Gen

ManMan

Gen

Ext

ManMan

Gen

Gen

ManManExt

Gen

ManManMan

ManExt

Gen

Man

Gen

Gen

Man

Ext

ManMan

ManMan

Man

Gen

ManManMan

Gen

ManManManManManMan

Man

Man

Gen

ManExt

ManExt

Uni

Man

Ext

Uni

Gen

Man

Ext

Ext

Man

Uni

Man

Gen

ManManMan

Man

Gen Gen

ManMan

ExtMan

ManMan

Gen

Man

UniUni

ManMan

GenGen

GenGen

Gen

ManGen

Man

Gen

Ext

Ext

ManManMan

Gen

ManManMan ManManMan

Uni

Man

GenMan

ExtExt

Ext

ManExt

Ext

ManMan

Gen

ManMan

Gen

Uni

Ext

Man

ExtMan

Ext

Man

ExtExt

Gen

Ext None

Man

ManExt

Man ExtExt

Ext

ManExtExt

None

Agr

ManManMan

Agr

NoneNone

Man

NoneNone

GenGenGen

ManMan

Gen

Gen

Ext

Man

Gen

Man

Man

Man ManMan

GenMan

Gen

Man Man

Ext

Gen

Uni

Man

Gen

ManExtMan

Gen

Gen

GenGen

GenGenMan

ManMan

Gen

Gen

Uni

ManMan

ManNone

ExtMan ManMan

Uni

Ext

ManMan

Uni

ManMan

Gen

Gen

Man

Man

ManMan

ManManManManMan

Agr

Ext

Gen

ManMan

Man

Ext

Gen

ManManMan

Gen

ManMan Gen

GenGenGen

Man

Gen

Man

GenGen

ManMan

GenGenGen

Gen

Man

Ext

Gen

ExtExt

Gen

Ext

Man

Ext

Man

Man

ManMan

GenGen

Ext

GenGen

Man

Man

Gen

Gen

ManMan

Gen

Man

Uni

Uni

Uni

Gen

ManMan

Ext

Gen

UniUni

Man

GenGen Gen

UniUni

Gen

Uni

Man

GenGen

Gen

Uni

Man

Man

Man

Gen

Uni

Man

Gen

Uni

ExtMan

ManGen

Gen

Man

Uni

GenMan

Man

AgrGen

Uni

Man

Ext

ManMan

Uni

Ext

UniUniUni

ExtExtExt

Gen

Uni

GenGen

Uni

Ext

Man

Uni

Gen

Grls

Uni

Gen

Ext

UniUni

Ext

Ext

Grls

Uni

Ext ExtExt

Uni

Ext

GrlsExt

Ext

UniUni

Gen

Uni Agr

Ext

Grls Gen

Uni

Man

GrlsGrls

Gen

UniUni

UniUni

Ext

Uni

Man

UniUniUni

Man

Uni

GenGen

Uni

Gen

ManMan

Uni

Ext

Gen

ManMan

GenGen

Man

Gen

Uni

ManGen

Gen

Gen

Ext

Uni

Man Man

Uni

Gen

Man

Gen

Man

Man

GenGen

GenGen

Man

Gen

Man

Gen

GenGenGen

Ext

Uni

ManMan

Uni

Gen

ManMan

Uni

Man

Gen

Man

Gen

Uni

Gen

Gen

UniUni

Uni

Uni

Man

Uni

Man

Gen

GenGenGenGen

Uni

GenGen

GenGen

Man Ext

Ext

GenGenGen

ManManManMan

GenGen

GenAgr

Ext

Ext

ManGen

Ext

Uni

ManMan

ExtMan

ManMan

Ext

Uni

Man

Gen

Ext

Gen

Man

Man

Uni

Man

ManGen

Gen

ManMan

ManMan

Man

GenGen

Man

Gen

Man

Man

ManManManMan

Gen

Man

Gen

ManManMan

Ext

Agr

Man

Man

Ext

Man

Man

Ext

Man

Man

Man

Uni

Man

Ext

Man

Gen

ExtNone

Ext

−2 0 2 4 6

−4

−2

02

Labplot for IQ

Dimension 1

Dim

ensi

on 2

4

7

5

6

5 4

6

2

5

6

5 4444

6

55 445

55

33

5

5

5

7

4

5

5

66

7

5

6

6

5

666

88

66

77

6

6

5

8

6

6

6

5

7

8

6

7

53

5

7

6

76

6

5

6

43

64

5

1

76

5

7

7

77

4

7

6

55

5

8

4 4

76

8 8

6

4

7 9

4

77

9

7

9

6

5

7

5

8

5

6

46

7 8

56

66

5

6

3

5

4

7

9

7

67

77

5

455

55 5

7

6

77

67

6

5

77

1

67

4

6

6

67

4

3

555 455

2

4

45

5

33

44

34

4

5

555

33

5

3

6

5 54

5

66

34

33

4

3 3

654

5444

5

5

7

4

53

4

34

5

6

3

7

5

7

7

55

455

5

5

1

6

3

453

5

7

5

5 455

8

7

3

5

5

5 4

8

4

7

7

7

7

544

5

7

6

7

34 3

7

6

3

54

5

5

7

7

43

42

5

7

6

4

65

45

7

6

4

6

3

7

6

4

3

555

44544

3

8

5

3

4

3

8

2

4

55

6

5

5

4

7

9

7

8

6

5

66

9

6

76

5

7

5

6

5

67

6

5 4

6

44

87

5

87

8

7

5

666

5

7

7

6 7

55

87

5

6

5 4

7

3

5

6

3

5

3

6

4

5

45

5

5

5

345

6

4

5

345

6

5

7

455 55

76

5

3

6

5

7

5

3

4555

44

3

6

34 4

6

33

5

335

5

66

6

33

7

4

6

5

7

4

5

6

5

6

3

7

5

6

4

5

434

76

4

2

56

3

55

2

444

5

67

7

5

3

4

6

5

6

8

8

555

9

7 6

55

6

5

3

5

6

5

6

34

55

4

4

7

3

45

8

1 5

7

4

776

3

5

66

454

5

34

7

3

6

8

3

5

7

5

45

7

66

7

555

87

3

676

5

55

4

31

5

9

4

554

5

6

3

7

5

5

6

5

8

33

5

76

6

4

3

6

8

6

4

3

5

77

68

4

78

5

4

6

6

7

6

6

5

7

65

5

7

7

6

76

55

8

5

6

6

5

6

5

7

5

4

6

35

66

9

6

6

7 77

5

4

4

5

5

77

55

7

445

8

6

66

45

8

6

4 4

8

4

9

7

3

9

4

8

44

5

4

77

4

4

4

5

6

8

57

9

6

3

55

5

6

76

6

9

3

5

7 7

5

7

6

4

877

9

5

8

5

7

7

56

4

77

3

54

6

6

7

43

6

7

2

6

42

4

55 6

5 4

3

7

55

7

4

222

4444

5

5

5

33

4

6

44

7

4

6565

5 44

5

7

5

5

6

5

5

6

55

6

3

5 4

6

5

4 45

6

444

33

5

5

6

7

5

3

45

56

5

7

544

6

55 4455

5

6

6

56

35

7

6

4

8

7

6

3

5

5

7

5

6

555

4

6 5

54

34

45

7

5

87

55

77

56

6

65

3

5

3

6

433

6

5 45 45 5

8

5

46

45

3

45

5

33

7

44

6

8

4

4

54

3

5

34

7

3 3

5

33

4 45

3

44 4

3

4

555

5

44

4

23

777

44

5

6

3

4

5

6

3

5 45

67

7

5 4

4

7

8

4

6

543

7

5

77

6 77

55

7

5

9

66

34

45 45

8

2

45

7

44

5

6

5

6

55

345 45

6

2

7

67

5

3

7

5 45

5

45 3

66 6

6

8

5

77

34

555

6

5

3

6

53

5

5

5

2

5

3

53

66

4

55

3

5

6

5

55

7

4

7

9

7

7

55

3

6

77

5

66 5

88

6

8

5

5 5

7

8

5

6

5

5

8

4

6

9

65

65

6

5

7

55

5

46

9

5

3

45

8

6

778

455

7

8

66

6

7

5

8

6

5

7

7

7

8 8

4

6

5

7

5 45

6

6

78

4

7 7

6

5 5

5

6 6

7

4

67

5

76

77

4

6

3

887

5

9

67

7

6

5 4

8

4

6

55

66

4

4

7

55

6

5

4

7

5 4

7

6

5

6

5

6

66

77

4

6

5

6

555

5

8

45

8

6

55

7

5

6

5

5

7

6

7

87

8

7

4

7

5

7

66 76

7

66

56

4 4

3

555

5 455

54

76

4

2

55

3

7

55

55

64

5

6

5

6

4

5

5

6

8

4

55

6

44

45

3

66

4

7

5

3

5 4 45

6

5

6

444

4

4

4

5

4

5

4

3

5

6

4

8

5

3

6

7

32

3

Figure 3: Voronoi Plot and Label Plot for Galo Data

To demonstrate this, we use the galo dataset (Peschar 1975) where data of 1290 schoolchildren in the sixth grade of an elementary school in the city of Groningen (Netherlands)were collected. The variables are Gender, IQ (categorized into 9 ordered categories), Advice(teacher categorized the children into 7 possible forms of secondary education, i.e., Agr =agricultural; Ext = extended primary education; Gen = general; Grls = secondary schoolfor girls; Man = manual, including housekeeping; None = no further education; Uni = pre-University), SES (parent’s profession in 6 categories) and School (37 different schools). Inthis example it could be of interest to predict Advice from Gender, IQ, and SES (whereasSchool is inactive).

> data("galo")

> res <- homals(galo, active = c(rep(TRUE, 4), FALSE), sets = list(c(1,

+ 2, 4), 3, 5))

Loss function increases in iteration 6

> predict(res)

Classification rate:

Variable Cl. Rate %Cl. Rate

Page 14: Gifi Methods for Optimal Scaling in R: The Package homals

14 Homals in R

1 gender 0.6488 64.88

2 IQ 0.6039 60.39

3 advice 0.7845 78.45

4 SES 0.3504 35.04

5 School 0.0171 1.71

> plot(res, plot.type = "vorplot", var.subset = 3, asp = 1)

> plot(res, plot.type = "labplot", var.subset = 2, asp = 1)

A rate of .6310 correctly classified teacher advice results. The Voronoi plot in Figure 3 showsthe Voronoi regions for the same variable. A labeled plot is given for the IQs which showsthat on the upper half of the horseshoe there are mainly children with IQ-categories 7-9.Distinctions between these levels of intelligence are mainly reflected by Dimension 1. Forthe lower horseshoe half it can be stated that both dimensions reflect differences in lowerIQ-categories.

Using the classical iris dataset, the aim is to predict Species from Petal/Sepal Length/Width.The polynomial level constraint is posed on the predictors and the response is treated asnominal. A hull plot for the response, a label plot Petal Length and loss plots for all predictorsare produced.

> data("iris")

> res <- homals(iris, sets = list(1:4, 5), level = c(rep("polynomial",

+ 4), "nominal"), rank = 2, itermax = 2000)

> plot(res, plot.type = "hullplot", var.subset = 5, cex = 0.7,

+ xlim = c(-3, 3), ylim = c(-4, 3), asp = 1)

> plot(res, plot.type = "labplot", var.subset = 3, cex = 0.7, xlim = c(-3,

+ 3), ylim = c(-4, 3), asp = 1)

For this two-dimensional homals solution, 100% of the iris species are correctly classified.The hullplot in Figure 4 shows that the species are clearly separated on the two-dimensionalplane. In the label plot the object scores are labeled with the response on Petal Length andit becomes obvious that small lengths form the setosa “cluster”, whereas iris virginica arecomposed by obervations with large petal lengths. Iris versicolor have medium lengths.

The loss plots in Figure 5 show the fitted rank-2 solution (red lines) against the unrestrictedsolution. The implication of the polynomial level restriction for the fitted model is obvious.

> plot(res, plot.type = "lossplot", var.subset = 1:4, cex = 0.7,

+ xlim = c(-3, 3), ylim = c(-5, 3), asp = 1)

To show another homals application of predictive (in this case regression) modeling we use theNeumann dataset (Wilson 1926): Willard Gibbs discovered a theoretical formula connectingthe density, the pressure, and the absolute temperature of a mixture of gases with convertiblecomponents. He applied this formula and the estimated constants to 65 experiments carriedout by Neumann, and he discusses the systematic and accidental divergences (residuals). Inthe homals package such a linear regression of density on temperature and pressure can beemulated by setting numerical levels. Constraining the levels to be ordinal, we get a monotoneregression (Gifi 1990).

Page 15: Gifi Methods for Optimal Scaling in R: The Package homals

Jan de Leeuw, Patrick Mair 15

−4 −2 0 2 4

−4

−3

−2

−1

01

23

Hullplot for Species

Dimension 1

Dim

ensi

on 2

setosa

setosa

setosa

setosasetosasetosa

versicolorversicolor

versicolorversicolor

versicolorversicolor

versicolor

virginica

virginica

virginica

virginicavirginicavirginicavirginica

virginica

virginica

−4 −2 0 2 4

−4

−3

−2

−1

01

23

Labplot for Petal.Length

Dimension 1D

imen

sion

2

1.41.41.31.5

1.4

1.71.41.51.4

1.51.51.61.4

1.11.2

1.51.31.41.7

1.51.71.5

1

1.7

1.91.61.6

1.51.41.61.61.5

1.51.4

1.51.21.3

1.41.31.51.3

1.3

1.3

1.61.91.4

1.61.41.51.4

4.7

4.54.944.6

4.54.73.3

4.6

3.93.54.24

4.73.6

4.4

4.5

4.14.5

3.9

4.8

4

4.94.7

4.34.44.8

54.53.53.83.73.9

5.14.54.5

4.74.4

4.14

4.44.64

3.34.24.24.24.3

34.1

6

5.1

5.95.6

5.86.6

4.5

6.35.8

6.1

5.15.35.55

5.15.3

5.5

6.76.9

5

5.7

4.9

6.7

4.9

5.7

6

4.84.9

5.6

5.8

6.1

6.45.6

5.1

5.6

6.1

5.6

5.5

4.8

5.4

5.6

5.15.1

5.95.7

5.2

5

5.2

5.4

5.1

Figure 4: Hullplot and Label Plot for Iris Data

> data("neumann")

> res.lin <- homals(neumann, sets = list(3, 1:2), level = "numerical",

+ rank = 1)

> res.mon <- homals(neumann, sets = list(3, 1:2), level = "ordinal",

+ rank = 1)

> plot(res.lin, plot.type = "loadplot", main = "Loadings Plot Linear Regression",

+ xlim = c(-10, 10), ylim = c(-5, 10), asp = 1)

> plot(res.mon, plot.type = "loadplot", main = "Loadings Plot Monotone Regression",

+ xlim = c(-10, 10), ylim = c(-5, 10), asp = 1)

The points in the loadings plot in Figure 6 correspond to regression coefficients.

The impact of the level restrictions on the scaling is visualized in the transformation plots inFigure 7. Numerical level restrictions lead to linear transformations of the original scale withrespect to the homals scaling (i.e. linear regression). Pertaining to ordinal levels, monotonetransformations are carried out (i.e. monotone regression).

4.3. NLPCA on Roskam data

Roskam (1968) collected preference data where 39 psychologists ranked all nine areas (seeTable 1) of the Psychology Department at the University of Nijmengen.

Using this data set we will perform two-dimensional NLPCA by restricting the rank to be 1.Note that the objects are the areas and the variables are the psychologists. Thus, the inputdata structure is a 9× 39 data frame. Note that the scale level is set to “ordinal”.

> data("roskam")

> res <- homals(roskam, rank = 1, level = "ordinal")

> plot(res, plot.type = "objplot", xlim = c(-2.5, 2.5), ylim = c(-2.5,

Page 16: Gifi Methods for Optimal Scaling in R: The Package homals

16 Homals in R

●●

●●

●●

●●

● ● ● ● ●●●●●●●●●●●●●●●●

−4 −2 0 2 4

−4

−2

02

Lossplot for Sepal.Length

Dimension 1

Dim

ensi

on 2

4.34.4

4.54.6

4.74.84.955.15.25.35.45.55.65.75.85.966.16.26.36.46.56.66.76.8

6.97

7.17.27.37.47.67.77.9

●●●

●●

●●

●●

●●●

●●●

●●●

●●●●

●●

4.34.4

4.5

4.64.74.84.9

55.15.2

5.3

5.4

5.5 5.65.7

5.8

5.966.1

6.2

6.36.46.5

6.6

6.76.86.9

7

7.17.27.37.4

7.67.7

7.9

●●

●●

●●

●●

●●●●●●●●●●●

−4 −2 0 2 4

−4

−2

02

Lossplot for Sepal.Width

Dimension 1

Dim

ensi

on 2

22.22.32.4

2.52.6

2.72.8

2.933.13.23.33.43.53.63.73.83.944.14.24.4

●●

●●●

●●

●●

●●●●

2

2.22.3

2.4

2.52.62.7

2.8

2.9

33.13.2

3.3

3.43.5

3.6

3.7

3.8

3.94

4.14.2

4.4

●●

●●

●●

●●●●●●●●●●●●

●●●●●●●

−4 −2 0 2 4

−4

−2

02

Lossplot for Petal.Length

Dimension 1

Dim

ensi

on 2

11.1

1.21.3

1.41.5

1.61.7

1.933.33.53.63.73.83.944.14.24.34.44.54.64.74.84.95

5.15.25.35.45.55.65.75.85.96

6.16.36.4

6.6

6.7

6.9

●●●

●●●●●●

●●●●●●●

●●●

●●

●●

●●

●●●●●

●●

●●

●●

11.11.21.31.41.51.6

1.71.9

33.33.53.63.73.83.944.14.24.34.4

4.5

4.64.7

4.84.9

5

5.15.25.35.45.5

5.65.7

5.8

5.9

6

6.16.36.4

6.66.7

6.9

●●

● ● ● ●●

−4 −2 0 2 4

−4

−2

02

Lossplot for Petal.Width

Dimension 1

Dim

ensi

on 2

0.1

0.2

0.30.4

0.50.6

11.11.21.31.41.51.61.71.81.9

2

2.1

2.2

2.3

2.4

2.5

●●●●

●●

●●●●

●●

●●

●●

●●

0.10.20.30.4

0.50.6

11.11.21.31.41.5

1.61.7

1.81.922.1

2.2

2.32.4

2.5

Figure 5: Loss plots for Iris Predictors

+ 2.5), asp = 1)

> plot(res, plot.type = "vecplot", var.subset = 2, main = "Vector Plot Rater 2",

+ xlim = c(-2.5, 2.5), ylim = c(-2.5, 2.5), asp = 1)

The object plot in Figure 8 shows interesting rating “twins” of departmental areas: mathe-matical and experimental psychology, industrial psychology and test construction (both areclose to the former two areas), educational and social psychology, clinical and cultural psy-chology. Physiological and animal psychology are somewhat separated from the other areas.Obviously this rater is attracted to areas like social, cultural and clinical psychology ratherthan to methodological fields. The vector plot on the right hand side projects the categoryscores onto a straight line determined by rank restricted category quantifications. Similarly,a projection plot could be created. Further analyses of this dataset within a PCA contextcan be found in de Leeuw (2006).

Page 17: Gifi Methods for Optimal Scaling in R: The Package homals

Jan de Leeuw, Patrick Mair 17

−10 −5 0 5 10

−5

05

10Loadings Plot Linear Regression

Dimension 1

Dim

ensi

on 2

temperature

pressure

density

−10 −5 0 5 10

−5

05

10

Loadings Plot Monotone Regression

Dimension 1

Dim

ensi

on 2

temperature

pressure

density

Figure 6: Loading Plots for Neumann Regression

SOC Social PsychologyEDU Educational and Developmental PsychologyCLI Clinical Psychology

MAT Mathematical Psychology and Psychological StatisticsEXP Experimental PsychologyCUL Cultural Psychology and Psychology of ReligionIND Industrial PsychologyTST Test Construction and ValidationPHY Physiological and Animal Psychology

Table 1: Psychology Areas in Roskam Data.

5. Discussion

In this paper theoretical foundations of the methodology used in the homals package are elabo-rated and package application and visualization issues are presented. Basically, homals coversthe techniques described in Gifi (1990): Homogeneity analysis, NLCCA, predictive models,and NLPCA. It can handle missing data and the scale level of the variables can be taken intoaccount. The package offers a broad variety of real-life datasets and furthermore provides nu-merous methods of visualization, either in a two-dimensional or in a three-dimensional way.Future enhancements will be to replace indicator matrices by more general B-spline basesand to incorporate weights for observations. To conclude, homals provides flexible, easy-to-use routines which allow researchers from different areas to compute, interpret, and visualizemethods belonging to the Gifi family.

References

ADA (2002). “Voting Record: Shattered Promise of Liberal Progress.” ADA Today, 57(1),

Page 18: Gifi Methods for Optimal Scaling in R: The Package homals

18 Homals in R

−0.

15−

0.05

0.05

0.15

Transformation plot for temperature

original scale

tran

sfor

med

sca

le

78 100 110 120 130 140 150 160 185

linearmonotone

−0.

10.

00.

10.

20.

30.

4

Transformation plot for pressure

original scale

tran

sfor

med

sca

le

66 93 113 164 197 243 335 432

linearmonotone

−0.

15−

0.05

0.05

0.15

Transformation plot for temperature

original scale

tran

sfor

med

sca

le

78 100 110 120 130 140 150 160 185

linearmonotone

Figure 7: Transformation Plots for Neumann Regression

1–17.

Benzecri JP (1973). Analyse des Donnees. Dunod, Paris, France.

de Leeuw J (2006). “Nonlinear Principal Component Analysis and Related Techniques.” InM˜Greenacre, J˜Blasius (eds.), “Multiple Correspondence Analysis and Related Methods,”pp. 107–134. Chapman & Hall/CRC, Boca Raton, FL.

de Leeuw J, Michailidis G, Wang D (1999). “Correspondence Analysis Techniques.” InS˜Ghosh (ed.), “Multivariate Analysis, Design of Experiments, and Survey Sampling,” pp.523–546. Dekker, New York.

Gifi A (1990). Nonlinear Multivariate Analysis. Wiley, Chichester, England.

Page 19: Gifi Methods for Optimal Scaling in R: The Package homals

Jan de Leeuw, Patrick Mair 19

−3 −2 −1 0 1 2 3

−2

−1

01

2

Plot Object Scores

Dimension 1

Dim

ensi

on 2

SOCEDU

CLI

MATEXP

CUL

INDTST

PHY

●●

●●

●●

−3 −2 −1 0 1 2 3

−2

−1

01

2

Vector Plot Rater 2

Dimension 1D

imen

sion

2

13

2

76

4

58

9

123 45 678

9

Figure 8: Plots for Roskam data

Greenacre M (1984). Theory and Applications of Correspondence Analysis. Academic Press,London, England.

Greenacre M, Blasius J (2006). Multiple Correspondence Analysis and Related Methods. Chap-man & Hall/CRC, Boca Raton, FL.

Mair P, de Leeuw J (2009). “Rank and Set Restrictions for Homogeneity Analysis in R.” In“JSM 2008 Proceedings, Statistical Computing Section,” American Statistical Association.,Alexandria, VA.

Mair P, Hatzinger R (2007). “Psychometrics Task View.” R-News, 7/3, 38–40.

Meulman JJ (1996). “Fitting a Distance Model to Homogeneous Subsets of Variables: Pointsof View Analysis of Categorical Data.” Journal of Classification, 13, 249–266.

Michailidis G, de˜Leeuw J (1998). “The Gifi System of Descriptive Multivariate Analysis.”Statistical Science, 13, 307–336.

Michailidis G, de Leeuw J (2001). “Data Visualization through Graph Drawing.” Computa-tional Statistics, 16, 435–450.

Nenadic O, Greenacre M (2006). “Correspondence Analysis in R, with Two- and Three-dimensional Graphics: The ca Package.” Journal of Statistical Software, 20(3), 1–13. URLhttp://www.jstatsoft.org/v20/i03/paper.

Peschar JL (1975). School, Milieu, Beroep. Tjeek Willink, Groningen, The Netherlands.

R Development Core Team (2008). R: A Language and Environment for Statistical Comput-ing. R Foundation for Statistical Computing, Vienna, Austria. ISBN 3-900051-07-0, URLhttp://www.R-project.org.

Page 20: Gifi Methods for Optimal Scaling in R: The Package homals

20 Homals in R

Roskam E (1968). Metric Analysis of Ordinal Data in Psychology. Ph.D. thesis, Universityof Leiden.

Takane Y (2005). “Optimal Scaling.” In B˜Everitt, D˜Howell (eds.), “Encyclopedia of Statis-tics for Behavioral Sciences,” pp. 1479–1482. Wiley, Chichester.

van der Burg E, de Leeuw J, Dijksterhuis G (1994). “OVERALS: Nonlinear Canonical Cor-relation with k Sets of Variables.” Computational Statistics & Data Analysis, 18, 141–163.

van der Burg E, de Leeuw J, Verdegaal R (1988). “Homogeneity Analysis with k Sets ofVariables: An Alternating Least Squares Method with Optimal Scaling Features.” Psy-chometrika, 53, 177–197.

Wilson EB (1926). “Empiricism and Rationalism.” Science, 64, 47–57.

Affiliation:

Jan de LeeuwDepartment of StatisticsUniversity of California, Los AngelesE-mail: [email protected]: http://www.stat.ucla.edu/~deleeuw/