# moonplot

moonplot draws the Correspondence Analysis (CA) moonplot.

## Syntax

• moonplot(out)example
• moonplot(out,Name,Value)example

## Description

 moonplot(out) moonplot with all the default options.

 moonplot(out, Name, Value) moonplot with option changedimsign.

## Examples

expand all

### moonplot with all the default options.

Prepare the data.

load('csdPerceptions')
N=csdPerceptions;
out=CorAna(N,'plots',0);
moonplot(out);
Summary
Singular_value     Inertia      Accounted_for    Cumulative
______________    __________    _____________    __________

dim_1        0.54313          0.29499         0.7751        0.7751
dim_2         0.2544         0.064718        0.17005       0.94514
dim_3        0.11339         0.012857       0.033781       0.97893
dim_4       0.086748        0.0075251       0.019772        0.9987
dim_5         0.0167       0.00027887     0.00073275       0.99943
dim_6       0.013467       0.00018135     0.00047651       0.99991
dim_7      0.0059347        3.522e-05     9.2542e-05             1

ROW POINTS
Results for dimension: 1
Scores      CntrbPnt2In    CntrbDim2In
_________    ___________    ___________

Coke         -0.24282      0.054146       0.51564
V             0.44798       0.14366       0.93282
RedBull       0.47112       0.13662       0.92437
LiftPlus      0.46454      0.077496       0.89889
DietCoke    -0.091333     0.0010171      0.021869
Fanta         -1.2734       0.53874       0.88102
Lift          -0.5004      0.033995       0.34225
Pepsi        -0.27373      0.014328       0.35991

Results for dimension: 2
Scores     CntrbPnt2In    CntrbDim2In
________    ___________    ___________

Coke        -0.20254      0.17171        0.35874
V            0.11225     0.041108       0.058562
RedBull      0.13203     0.048907       0.072599
LiftPlus     0.14636     0.035066       0.089234
DietCoke    -0.53782      0.16075        0.75831
Fanta        0.46647      0.32953        0.11823
Lift        -0.49767      0.15326        0.33852
Pepsi       -0.26164     0.059666        0.32881

COLUMN POINTS
Results for dimension: 1
Scores      CntrbPnt2In    CntrbDim2In
_________    ___________    ___________

Kids             -1.3154        0.4257       0.92133
Teens           0.037207     0.0008574      0.016052
EnjoyLife      -0.078767     0.0020558       0.05637
PicksYouUp       0.48853       0.10076       0.88168
Refreshes       -0.29457      0.017537       0.21492
CheersYouUp     -0.23563      0.010974       0.82623
Energy           0.60133       0.14373       0.81498
Up_to_date       0.28737      0.025084       0.87766
Fun             -0.92306       0.20009       0.91969
WhenTired        0.45377      0.066061       0.92716
Relax              -0.25     0.0071446       0.20238

Results for dimension: 2
Scores     CntrbPnt2In    CntrbDim2In
________    ___________    ___________

Kids            0.36814       0.15199      0.072168
Teens          -0.23731       0.15898       0.65297
EnjoyLife        -0.294       0.13054        0.7853
PicksYouUp      0.17611      0.059685       0.11458
Refreshes      -0.41976       0.16232       0.43641
CheersYouUp    -0.05739     0.0029674      0.049015
Energy          0.27479       0.13681       0.17018
Up_to_date     0.080252     0.0089169      0.068448
Fun             0.23316      0.058191      0.058679
WhenTired       0.12237      0.021897      0.067425
Relax          -0.45464        0.1077        0.6693

-----------------------------------------------------------
Overview ROW POINTS
Mass       Score_1     Score_2     Inertia     CntrbPnt2In_1    CntrbPnt2In_2    CntrbDim2In_1    CntrbDim2In_2
________    _________    ________    ________    _____________    _____________    _____________    _____________

Coke         0.27089     -0.24282    -0.20254    0.030977       0.054146         0.17171          0.51564          0.35874
V            0.21116      0.44798     0.11225     0.04543        0.14366        0.041108          0.93282         0.058562
RedBull      0.18157      0.47112     0.13203    0.043598        0.13662        0.048907          0.92437         0.072599
LiftPlus     0.10594      0.46454     0.14636    0.025432       0.077496        0.035066          0.89889         0.089234
DietCoke    0.035968    -0.091333    -0.53782     0.01372      0.0010171         0.16075         0.021869          0.75831
Fanta       0.098012      -1.2734     0.46647     0.18039        0.53874         0.32953          0.88102          0.11823
Lift        0.040049      -0.5004    -0.49767    0.029301       0.033995         0.15326          0.34225          0.33852
Pepsi       0.056409     -0.27373    -0.26164    0.011744       0.014328        0.059666          0.35991          0.32881

Overview COLUMN POINTS
Mass       Score_1     Score_2      Inertia     CntrbPnt2In_1    CntrbPnt2In_2    CntrbDim2In_1    CntrbDim2In_2
________    _________    ________    _________    _____________    _____________    _____________    _____________

Kids           0.072579      -1.3154     0.36814       0.1363         0.4257          0.15199         0.92133         0.072168
Teens           0.18271     0.037207    -0.23731     0.015757      0.0008574          0.15898        0.016052          0.65297
EnjoyLife      0.097746    -0.078767      -0.294     0.010758      0.0020558          0.13054         0.05637           0.7853
PicksYouUp      0.12454      0.48853     0.17611     0.033712        0.10076         0.059685         0.88168          0.11458
Refreshes      0.059621     -0.29457    -0.41976     0.024072       0.017537          0.16232         0.21492          0.43641
CheersYouUp    0.058308     -0.23563    -0.05739    0.0039181       0.010974        0.0029674         0.82623         0.049015
Energy          0.11726      0.60133     0.27479     0.052026        0.14373          0.13681         0.81498          0.17018
Up_to_date     0.089603      0.28737    0.080252     0.008431       0.025084        0.0089169         0.87766         0.068448
Fun            0.069276     -0.92306     0.23316      0.06418        0.20009         0.058191         0.91969         0.058679
WhenTired      0.094641      0.45377     0.12237     0.021018       0.066061         0.021897         0.92716         0.067425
Relax          0.033721        -0.25    -0.45464     0.010414      0.0071446           0.1077         0.20238           0.6693

-----------------------------------------------------------
Legend
CntrbPnt2In = relative contribution of points to explain total Inertia of the latent dimension
The sum of the numbers in a column is equal to 1
CntrbDim2In = relative contribution of latent dimension to explain total Inertia of a point
CntrbDim2In_1+CntrbDim2In_2+...+CntrbDim2In_K=1


### moonplot with option changedimsign.

Prepare the data.

load('mobilephone')
N=mobilePhone;
out=CorAna(N,'plots',0);
% Use of option changedimsign
moonplot(out,'changedimsign',[true false])
Summary
Singular_value     Inertia      Accounted_for    Cumulative
______________    __________    _____________    __________

dim_1        0.47503          0.22565        0.65741       0.65741
dim_2        0.25226         0.063636        0.18539       0.84281
dim_3        0.20151         0.040605         0.1183       0.96111
dim_4        0.09015        0.0081271       0.023677       0.98478
dim_5       0.063381        0.0040172       0.011704       0.99649
dim_6       0.028981       0.00083991       0.002447       0.99893
dim_7       0.019133       0.00036609      0.0010666             1

ROW POINTS
Results for dimension: 1
Scores     CntrbPnt2In    CntrbDim2In
________    ___________    ___________

AAPTCellularOne     0.43774      0.074997       0.58204
NewTel              0.70084       0.18966       0.82774
OneTel              0.75509       0.29334       0.67859
Optus              -0.36684      0.099393       0.80005
Orange             0.080756     0.0030053      0.069512
Telstra            -0.48339       0.19667       0.63237
VirginMobile         0.2265      0.021753       0.23553
Vodafone           -0.42388       0.12118        0.7573

Results for dimension: 2
Scores     CntrbPnt2In    CntrbDim2In
________    ___________    ___________

AAPTCellularOne     0.20731     0.059649         0.13055
NewTel             0.088109      0.01063        0.013083
OneTel             -0.45615      0.37961         0.24765
Optus              0.013396      0.00047       0.0010669
Orange              0.21336     0.074391         0.48523
Telstra            -0.27412      0.22427         0.20335
VirginMobile         0.3793      0.21631         0.66047
Vodafone            0.12041     0.034671        0.061103

COLUMN POINTS
Results for dimension: 1
Scores     CntrbPnt2In    CntrbDim2In
________    ___________    ___________

Bureaucratic                     -0.2099      0.010152       0.21808
LowService                        0.1333     0.0044122       0.47623
Friendly                        -0.13344      0.003972       0.12889
LowPrices                       0.071087     0.0011218      0.023653
Fashionable                     -0.13019      0.003816      0.062038
UnFashionable                    0.25692      0.017084       0.55182
Reliable                        -0.54443      0.062682       0.91686
HereTodayGoneTomorrow              1.183       0.26211       0.75899
GoodCoverage                    -0.73321      0.097851       0.82221
NetworkOftenDown                  0.2291      0.016622       0.78161
TheBestPhones                   -0.32977      0.022425       0.81958
ConvenientlyLocatedStores       -0.62787      0.090006       0.91678
HighPrices                      -0.41233      0.029157       0.43235
Unreliable                       0.59274      0.082434       0.81269
MeetMyCommunicationNeeds        -0.37965      0.029874       0.89117
ILikeThem                       -0.24443      0.014206       0.57453
IHateThem                        0.27763      0.026925       0.95031

Results for dimension: 2
Scores      CntrbPnt2In    CntrbDim2In
_________    ___________    ___________

Bureaucratic                     -0.25947      0.055008        0.33323
LowService                       -0.10801      0.010272        0.31265
Friendly                          0.29472      0.068702        0.62872
LowPrices                         0.33385      0.087739        0.52169
Fashionable                       0.39172       0.12251        0.56168
UnFashionable                    -0.10432     0.0099873       0.090972
Reliable                          -0.1167      0.010213       0.042129
HereTodayGoneTomorrow             -0.5778       0.22171        0.18105
GoodCoverage                      -0.2654      0.045464        0.10773
NetworkOftenDown                 0.034508     0.0013373       0.017733
TheBestPhones                    0.079656     0.0046398        0.04782
ConvenientlyLocatedStores       -0.051112      0.002115      0.0060753
HighPrices                       -0.26416      0.042436        0.17746
Unreliable                         -0.246      0.050349        0.13998
MeetMyCommunicationNeeds        0.0016326    1.9591e-06     1.6481e-05
ILikeThem                          0.1504      0.019074        0.21754
IHateThem                       -0.037841     0.0017737       0.017654

-----------------------------------------------------------
Overview ROW POINTS
Mass      Score_1     Score_2      Inertia     CntrbPnt2In_1    CntrbPnt2In_2    CntrbDim2In_1    CntrbDim2In_2
________    ________    ________    _________    _____________    _____________    _____________    _____________

AAPTCellularOne    0.088319     0.43774     0.20731     0.029076       0.074997        0.059649          0.58204           0.13055
NewTel             0.087132     0.70084    0.088109     0.051704        0.18966         0.01063          0.82774          0.013083
OneTel               0.1161     0.75509    -0.45615     0.097545        0.29334         0.37961          0.67859           0.24765
Optus               0.16667    -0.36684    0.013396     0.028034       0.099393         0.00047          0.80005         0.0010669
Orange              0.10399    0.080756     0.21336    0.0097562      0.0030053        0.074391         0.069512           0.48523
Telstra             0.18993    -0.48339    -0.27412     0.070181        0.19667         0.22427          0.63237           0.20335
VirginMobile       0.095679      0.2265      0.3793     0.020841       0.021753         0.21631          0.23553           0.66047
Vodafone            0.15218    -0.42388     0.12041     0.036108        0.12118        0.034671           0.7573          0.061103

Overview COLUMN POINTS
Mass      Score_1      Score_2      Inertia     CntrbPnt2In_1    CntrbPnt2In_2    CntrbDim2In_1    CntrbDim2In_2
________    ________    _________    _________    _____________    _____________    _____________    _____________

Bureaucratic                    0.051994     -0.2099     -0.25947     0.010505       0.010152         0.055008         0.21808           0.33323
LowService                       0.05603      0.1333     -0.10801    0.0020907      0.0044122         0.010272         0.47623           0.31265
Friendly                        0.050332    -0.13344      0.29472    0.0069537       0.003972         0.068702         0.12889           0.62872
LowPrices                       0.050095    0.071087      0.33385     0.010702      0.0011218         0.087739        0.023653           0.52169
Fashionable                     0.050807    -0.13019      0.39172      0.01388       0.003816          0.12251        0.062038           0.56168
UnFashionable                   0.058405     0.25692     -0.10432    0.0069862       0.017084        0.0099873         0.55182          0.090972
Reliable                        0.047721    -0.54443      -0.1167     0.015427       0.062682         0.010213         0.91686          0.042129
HereTodayGoneTomorrow            0.04226       1.183      -0.5778     0.077928        0.26211          0.22171         0.75899           0.18105
GoodCoverage                    0.041073    -0.73321      -0.2654     0.026855       0.097851         0.045464         0.82221           0.10773
NetworkOftenDown                0.071462      0.2291     0.034508    0.0047988       0.016622        0.0013373         0.78161          0.017733
TheBestPhones                   0.046534    -0.32977     0.079656    0.0061743       0.022425        0.0046398         0.81958           0.04782
ConvenientlyLocatedStores       0.051519    -0.62787    -0.051112     0.022154       0.090006         0.002115         0.91678         0.0060753
HighPrices                      0.038699    -0.41233     -0.26416     0.015218       0.029157         0.042436         0.43235           0.17746
Unreliable                      0.052944     0.59274       -0.246     0.022889       0.082434         0.050349         0.81269           0.13998
MeetMyCommunicationNeeds        0.046771    -0.37965    0.0016326    0.0075643       0.029874       1.9591e-06         0.89117        1.6481e-05
LeadersMobilePhoneTechnology    0.049383    -0.43259    -0.028765      0.00948       0.040952        0.0006421          0.9748         0.0043102
ILikeThem                       0.053656    -0.24443       0.1504    0.0055796       0.014206         0.019074         0.57453           0.21754
IHateThem                       0.078822     0.27763    -0.037841    0.0063933       0.026925        0.0017737         0.95031          0.017654
DonotKnowMuchAboutThem          0.061491     0.82215      0.50458     0.071665        0.18419          0.24602         0.57997           0.21845

-----------------------------------------------------------
Legend
CntrbPnt2In = relative contribution of points to explain total Inertia of the latent dimension
The sum of the numbers in a column is equal to 1
CntrbDim2In = relative contribution of latent dimension to explain total Inertia of a point
CntrbDim2In_1+CntrbDim2In_2+...+CntrbDim2In_K=1


## Input Arguments

### out — Structure containing the output of function CorAna. Structure.

Structure containing the following fields.

Value Description
Lr

cell of length $I$ containing the labels of active rows (i.e. the rows which participated to the fit).

Lc

cell of length $J$ containing the labels of active columns (i.e. the columns which participated to the fit).

n

Grand total. out.n is equal to sum(sum(out.N)).

This is the number of observations.

Dr

Square matrix of size $I$ containing on the diagonal the row masses. This is matrix $D_r$.

$D_r=diag(r)$

Dc

Square matrix of size $J$ containing on the diagonal the column masses. This is matrix $D_c$.

$D_c=diag(c)$

InertiaExplained

matrix with 4 columnn.

- First column contains the singular values (the sum of the squared singular values is the total inertia).

- Second column contains the eigenvalues (the sum of the eigenvalues is the total inertia).

- Third column contains the variance explained by each latent dimension.

- Fourth column contains the cumulative variance explained by each dimension.

LrSup

cell containing the labels of the supplementary rows (i.e. the rows whicg did not participate to the fit).

LcSup

cell containing the labels of supplementary columns (i.e. the columns which did not participate to the fit).

SupRowsN

matrix of size length(LrSup)-by-c referred to supplementary rows. If there are no supplementary rows this field is not present.

SupColsN

matlab of size r-by-length(LcSup) referred to supplementary columns.

If there are no supplementary columns this field is not present.

RowsPriSup

Principal coordinates of supplementary rows.

If there are no supplementary rows this field is not present.

RowsStaSup

Standard coordinates of supplementary rows.

If there are no supplementary rows this field is not present.

RowsSymSup

Symmetrical coordinates of supplementary rows.

If there are no supplementary rows this field is not present.

ColsPriSup

Principal coordinates of supplementary columns.

If there are no supplementary columns this field is not present.

ColsStaSup

Standard coordinates of of supplementary columns.

If there are no supplementary columns this field is not present.

ColsSymSup

Symmetrical coordinates of supplementary columns.

If there are no supplementary columns this field is not present.

Data Types: struct

### Name-Value Pair Arguments

Specify optional comma-separated pairs of Name,Value arguments. Name is the argument name and Value is the corresponding value. Name must appear inside single quotes (' '). You can specify several name and value pair arguments in any order as  Name1,Value1,...,NameN,ValueN.

Example:  'plots',plots=struct; plots.colorcols='k' , 'addx',0.01 , 'addy',0.01 , 'changedimsign', [true false] , 'xlimx',[-1 1] , 'ylimy',[0 1] , 'd1',2 , 'd2',3 ,'h',h1 where h1=subplot(2,1,1) 

### plots —Customize plot appearance.scalar | structure.

If plots is not a structure, a plot which shows the Principal coordinates of rows and columns is shown on the screen. If plots is a structure it may contain the following fields:

Value Description
alpha

type of plot, scalar in the interval [0 1] or a string identifying the type of coordinates to use in the plot.

If $plots.alpha='rowprincipal'$ the row points are in principal coordinates and the column coordinates are standard coordinates. Distances between row points are (approximated) chi-squared distances (row-metric-preserving). The position of the row points are at the weighted average of the column points.

Note that 'rowprincipal' can also be specified setting plots.alpha=1.

If $plots.alpha='colprincipal'$, the column coordinates are referred to as principal coordinates and the row coordinates as standard coordinates.

Distances between column points are (approximated) chi-squared distances (column-metric-preserving). The position of the column points are at the weighted average of the row points.

Note that 'colprincipal' can also be specified setting plots.alpha=0.

If $plots.alpha='symbiplot'$, the row and column coordinates are scaled similarly. The sum of weighted squared coordinates for each dimension is equal to the corresponding singular values. These coordinates are often called symmetrical coordinates. This representation is particularly useful if one is primarily interested in the relationships between categories of row and column variables rather than in the distances among rows or among columns. 'symbiplot' can also be specified setting plots.alpha=0.5;

If $plots.alpha='bothprincipal'$, both the rows and columns are depicted in principal coordinates. Such a plot is often referred to as a symmetrical plot or French symemtrical model. Note that such a symmetrical plot does not provide a feasible solution in the sense that it does not approximate matrix $D_r^{-0.5}(P-rc')D_c^{-0.5}$.

If $plots.alpha='bothstandard'$, both the rows and columns are depicted in standard coordinates.

If $plots.alpha='rowgab'$, rows are in principal coordinates and columns are in standard coordinates multiplied by the mass. This biplot has been suggested by Gabriel and Odoroff (1990).

If $plots.alpha='colgab'$, columns are in principal coordinates and rows are in standard coordinates multiplied by the mass. This biplot has been suggested by Gabriel and Odoroff (1990).

If $plots.alpha='rowgreen'$, rows are in principal coordinates and columns are in standard coordinates multiplied by square root of the mass.

This biplot has been suggested by Greenacre and incorporates the contribution of points. In this display, points that contribute very little to the solution, are close to the center of the biplot and are relatively unimportant to the interpretation. This biplot is often referred as contribution biplot because it visually shows the most contributing points (Greenacre 2006b).

If $plots.alpha='colgreen'$, columns in principal coordinates and rows in standard coordinates multiplied by the square root of the mass.

This biplot has been suggested by Greenacre and incorporates the contribution of points. In this display, points that contribute very little to the solution, are close to the center of the biplot and are relatively unimportant to the interpretation. This biplot is often referred as contribution biplot because it shows visually the most contributing points (Greenacre 2006b).

If $plots.alpha=scalar$ in the interval [0 1], row coordinates are given by $D_r^{-1/2} U \Gamma^\alpha$ and column coordinates are given by $D_c^{-1/2} V \Gamma^{1-\alpha}$. Note that for any choice of $\alpha$ the matrix product $D_r^{-1/2} U \Gamma^\alpha (D_c^{-1/2} V \Gamma^{1-\alpha})^T$ optimally approximates matrix $D_r^{-0.5}(P-rc')D_c^{-0.5}$, in the sense that the sum of squared differences between $D_r^{1/2} D_r^{-1/2} U \Gamma^\alpha (D_c^{-1/2} V \Gamma^{1-\alpha})^T D_c^{1/2}$ and $D_r^{-0.5}(P-rc')D_c^{-0.5}$ is as small as possible.

FontSize

scalar which specifies the font size of row labels. The default value is 10.

FontSizeSup

scalar which specifies the font size of row labels of supplementary points. The default value is 10.

MarkerSize

scalar which specifies the marker size of symbols associated with rows. The default value is 10.

SymbolRows

character which specifies the symbol to use for row points. If this field is not present the default symbols is 'o'.

SymbolRowsSup

character which specifies the symbol to use for supplementary row points. If this field is not present the default symbols is 'o'.

ColorRows

character which specifies the symbol to use for row points or RGB triplet. If this field is not present the default color is 'b'.

ColorCols

character which specifies the symbol to use for column points or RGB triplet. If this field is not present the default color is 'r'.

ColorRowsSup

character which specifies the symbol to use for row points or RGB triplet. If this field is not present the default color is 'b'.

ColorColsSup

character which specifies the symbol to use for supplementary column points or RGB triplet. If this field is not present the default color is 'r'.

MarkerFaceColorRows

character which specifies the marker fill color to use for active row points or RGB triplet. If this field is not present the default color is 'auto'.

MarkerFaceColorRowsSup

character which specifies the marker fill color to use for supplementary row points or RGB triplet. If this field is not present the default color is 'auto'.

Example:  'plots',plots=struct; plots.colorcols='k' 

Data Types: double

### addx —horizontal displacement for labels.scalar.

Amount of horizontal displacement which has been put on the labels in the plot. The defalut value of addx is 0.04.

Example:  'addx',0.01 

Data Types: double

### addy —vertical displacement for labels.scalar.

Amount of vertical displacement which has been put on the labels in the plot. The defalut value of addy is 0.

Example:  'addy',0.01 

Data Types: double

### changedimsign —change chosen dimension sign.boolean vector of length 2.

Sometimes for better interpretability it is necessary to change the sign of the coordinates for the chosen dimension. If changedimsign(1) is true the sign of the coordinates for first chosen dimension is changed. If changedimsign(2) is true the sign of the coordinates for first chosen dimension is changed. As default the dimensions are the first and the second however, they can be changed using option plots.dim. The defaul value of changedimsign is [false false] that is the sign is not changed.

Example:  'changedimsign', [true false] 

Data Types: boolean

### xlimx —Min and Max of the x axis.vector.

Vector with two elements controlling minimum and maximum of the x axis.

Example:  'xlimx',[-1 1] 

Data Types: double

### ylimy —Min and Max of the y axis.vector.

Vector with two elements controlling minimum and maximum of the y axis.

Example:  'ylimy',[0 1] 

Data Types: double

### d1 —Dimension to show on the horizontal axis.positive integer.

Positive integer in the range 1, 2, .., K which indicates the dimension to show on the x axis. The default value of d1 is 1.

Example:  'd1',2 

Data Types: single | double

### d2 —Dimension to show on the vertical axis.positive integer.

Positive integer in the range 1, 2, .., K which indicates the dimension to show on the y axis. The default value of d2 is 2.

Example:  'd2',3 

Data Types: single | double

### h —the axis handle of a figure where to send the moonplot.this can be used to host the moonplot in a subplot of a complex figure formed by different panels (for example a panel with moonplot from plots.

alpha=0.2 and another with moonplot from plots.alpha=0.5).

Example: 'h',h1 where h1=subplot(2,1,1) 

Data Types: Axes object (supplied as a scalar)

## References

Benzecri, J.-P. (1992), "Correspondence Analysis Handbook", New-York, Dekker.

Benzecri, J.-P. (1980), "L'analyse des donnees tome 2: l'analyse des correspondances", Paris, Bordas.

Greenacre, M.J. (1993), "Correspondence Analysis in Practice", London, Academic Press.

Bock, T. (2011), Improving the display of correspondence analysis using moon plots, "International Journal of Market Research", Vol. 53, pp. 307-326.

Gabriel, K.R. and Odoroff, C. (1990), Biplots in biomedical research, "Statistics in Medicine", Vol. 9, pp. 469-485.

Greenacre, M.J. (1993), Biplots in correspondence Analysis, "Journal of Applied Statistics", Vol. 20, pp. 251-269.