-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathindex.tex
18878 lines (15291 loc) · 912 KB
/
index.tex
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
% Options for packages loaded elsewhere
\PassOptionsToPackage{unicode}{hyperref}
\PassOptionsToPackage{hyphens}{url}
\PassOptionsToPackage{dvipsnames,svgnames,x11names}{xcolor}
%
\documentclass[
letterpaper,
10pt,
krantz2]{krantz}
\usepackage{amsmath,amssymb}
\usepackage{iftex}
\ifPDFTeX
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{textcomp} % provide euro and other symbols
\else % if luatex or xetex
\usepackage{unicode-math}
\defaultfontfeatures{Scale=MatchLowercase}
\defaultfontfeatures[\rmfamily]{Ligatures=TeX,Scale=1}
\fi
\usepackage{lmodern}
\ifPDFTeX\else
% xetex/luatex font selection
\fi
% Use upquote if available, for straight quotes in verbatim environments
\IfFileExists{upquote.sty}{\usepackage{upquote}}{}
\IfFileExists{microtype.sty}{% use microtype if available
\usepackage[]{microtype}
\UseMicrotypeSet[protrusion]{basicmath} % disable protrusion for tt fonts
}{}
\makeatletter
\@ifundefined{KOMAClassName}{% if non-KOMA class
\IfFileExists{parskip.sty}{%
\usepackage{parskip}
}{% else
\setlength{\parindent}{0pt}
\setlength{\parskip}{6pt plus 2pt minus 1pt}}
}{% if KOMA class
\KOMAoptions{parskip=half}}
\makeatother
\usepackage{xcolor}
\usepackage[top=20mm,left=25mm]{geometry}
\ifLuaTeX
\usepackage{luacolor}
\usepackage[soul]{lua-ul}
\else
\usepackage{soul}
\fi
\setlength{\emergencystretch}{3em} % prevent overfull lines
\setcounter{secnumdepth}{5}
% Make \paragraph and \subparagraph free-standing
\ifx\paragraph\undefined\else
\let\oldparagraph\paragraph
\renewcommand{\paragraph}[1]{\oldparagraph{#1}\mbox{}}
\fi
\ifx\subparagraph\undefined\else
\let\oldsubparagraph\subparagraph
\renewcommand{\subparagraph}[1]{\oldsubparagraph{#1}\mbox{}}
\fi
\usepackage{color}
\usepackage{fancyvrb}
\newcommand{\VerbBar}{|}
\newcommand{\VERB}{\Verb[commandchars=\\\{\}]}
\DefineVerbatimEnvironment{Highlighting}{Verbatim}{commandchars=\\\{\}}
% Add ',fontsize=\small' for more characters per line
\usepackage{framed}
\definecolor{shadecolor}{RGB}{241,243,245}
\newenvironment{Shaded}{\begin{snugshade}}{\end{snugshade}}
\newcommand{\AlertTok}[1]{\textcolor[rgb]{0.68,0.00,0.00}{#1}}
\newcommand{\AnnotationTok}[1]{\textcolor[rgb]{0.37,0.37,0.37}{#1}}
\newcommand{\AttributeTok}[1]{\textcolor[rgb]{0.40,0.45,0.13}{#1}}
\newcommand{\BaseNTok}[1]{\textcolor[rgb]{0.68,0.00,0.00}{#1}}
\newcommand{\BuiltInTok}[1]{\textcolor[rgb]{0.00,0.23,0.31}{#1}}
\newcommand{\CharTok}[1]{\textcolor[rgb]{0.13,0.47,0.30}{#1}}
\newcommand{\CommentTok}[1]{\textcolor[rgb]{0.37,0.37,0.37}{#1}}
\newcommand{\CommentVarTok}[1]{\textcolor[rgb]{0.37,0.37,0.37}{\textit{#1}}}
\newcommand{\ConstantTok}[1]{\textcolor[rgb]{0.56,0.35,0.01}{#1}}
\newcommand{\ControlFlowTok}[1]{\textcolor[rgb]{0.00,0.23,0.31}{#1}}
\newcommand{\DataTypeTok}[1]{\textcolor[rgb]{0.68,0.00,0.00}{#1}}
\newcommand{\DecValTok}[1]{\textcolor[rgb]{0.68,0.00,0.00}{#1}}
\newcommand{\DocumentationTok}[1]{\textcolor[rgb]{0.37,0.37,0.37}{\textit{#1}}}
\newcommand{\ErrorTok}[1]{\textcolor[rgb]{0.68,0.00,0.00}{#1}}
\newcommand{\ExtensionTok}[1]{\textcolor[rgb]{0.00,0.23,0.31}{#1}}
\newcommand{\FloatTok}[1]{\textcolor[rgb]{0.68,0.00,0.00}{#1}}
\newcommand{\FunctionTok}[1]{\textcolor[rgb]{0.28,0.35,0.67}{#1}}
\newcommand{\ImportTok}[1]{\textcolor[rgb]{0.00,0.46,0.62}{#1}}
\newcommand{\InformationTok}[1]{\textcolor[rgb]{0.37,0.37,0.37}{#1}}
\newcommand{\KeywordTok}[1]{\textcolor[rgb]{0.00,0.23,0.31}{#1}}
\newcommand{\NormalTok}[1]{\textcolor[rgb]{0.00,0.23,0.31}{#1}}
\newcommand{\OperatorTok}[1]{\textcolor[rgb]{0.37,0.37,0.37}{#1}}
\newcommand{\OtherTok}[1]{\textcolor[rgb]{0.00,0.23,0.31}{#1}}
\newcommand{\PreprocessorTok}[1]{\textcolor[rgb]{0.68,0.00,0.00}{#1}}
\newcommand{\RegionMarkerTok}[1]{\textcolor[rgb]{0.00,0.23,0.31}{#1}}
\newcommand{\SpecialCharTok}[1]{\textcolor[rgb]{0.37,0.37,0.37}{#1}}
\newcommand{\SpecialStringTok}[1]{\textcolor[rgb]{0.13,0.47,0.30}{#1}}
\newcommand{\StringTok}[1]{\textcolor[rgb]{0.13,0.47,0.30}{#1}}
\newcommand{\VariableTok}[1]{\textcolor[rgb]{0.07,0.07,0.07}{#1}}
\newcommand{\VerbatimStringTok}[1]{\textcolor[rgb]{0.13,0.47,0.30}{#1}}
\newcommand{\WarningTok}[1]{\textcolor[rgb]{0.37,0.37,0.37}{\textit{#1}}}
\providecommand{\tightlist}{%
\setlength{\itemsep}{0pt}\setlength{\parskip}{0pt}}\usepackage{longtable,booktabs,array}
\usepackage{calc} % for calculating minipage widths
% Correct order of tables after \paragraph or \subparagraph
\usepackage{etoolbox}
\makeatletter
\patchcmd\longtable{\par}{\if@noskipsec\mbox{}\fi\par}{}{}
\makeatother
% Allow footnotes in longtable head/foot
\IfFileExists{footnotehyper.sty}{\usepackage{footnotehyper}}{\usepackage{footnote}}
\makesavenoteenv{longtable}
\usepackage{graphicx}
\makeatletter
\def\maxwidth{\ifdim\Gin@nat@width>\linewidth\linewidth\else\Gin@nat@width\fi}
\def\maxheight{\ifdim\Gin@nat@height>\textheight\textheight\else\Gin@nat@height\fi}
\makeatother
% Scale images if necessary, so that they will not overflow the page
% margins by default, and it is still possible to overwrite the defaults
% using explicit options in \includegraphics[width, height, ...]{}
\setkeys{Gin}{width=\maxwidth,height=\maxheight,keepaspectratio}
% Set default figure placement to htbp
\makeatletter
\def\fps@figure{htbp}
\makeatother
% definitions for citeproc citations
\NewDocumentCommand\citeproctext{}{}
\NewDocumentCommand\citeproc{mm}{%
\begingroup\def\citeproctext{#2}\cite{#1}\endgroup}
\makeatletter
% allow citations to break across lines
\let\@cite@ofmt\@firstofone
% avoid brackets around text for \cite:
\def\@biblabel#1{}
\def\@cite#1#2{{#1\if@tempswa , #2\fi}}
\makeatother
\newlength{\cslhangindent}
\setlength{\cslhangindent}{1.5em}
\newlength{\csllabelwidth}
\setlength{\csllabelwidth}{3em}
\newenvironment{CSLReferences}[2] % #1 hanging-indent, #2 entry-spacing
{\begin{list}{}{%
\setlength{\itemindent}{0pt}
\setlength{\leftmargin}{0pt}
\setlength{\parsep}{0pt}
% turn on hanging indent if param 1 is 1
\ifodd #1
\setlength{\leftmargin}{\cslhangindent}
\setlength{\itemindent}{-1\cslhangindent}
\fi
% set entry spacing
\setlength{\itemsep}{#2\baselineskip}}}
{\end{list}}
\usepackage{calc}
\newcommand{\CSLBlock}[1]{\hfill\break\parbox[t]{\linewidth}{\strut\ignorespaces#1\strut}}
\newcommand{\CSLLeftMargin}[1]{\parbox[t]{\csllabelwidth}{\strut#1\strut}}
\newcommand{\CSLRightInline}[1]{\parbox[t]{\linewidth - \csllabelwidth}{\strut#1\strut}}
\newcommand{\CSLIndent}[1]{\hspace{\cslhangindent}#1}
\usepackage{booktabs}
\usepackage{longtable}
\usepackage[bf,singlelinecheck=off]{caption}
\usepackage{url}
\usepackage{framed,color}
\definecolor{shadecolor}{RGB}{248,248,248}
% custom colors
\definecolor{darkgreen}{RGB}{1,50,32}
\renewcommand{\textfraction}{0.05}
\renewcommand{\topfraction}{0.8}
\renewcommand{\bottomfraction}{0.8}
\renewcommand{\floatpagefraction}{0.75}
% krantz VF format is ugly!
%\renewenvironment{quote}{\begin{VF}}{\end{VF}}
\let\oldhref\href
\providecommand{\href}[2]{#2\footnote{\url{#1}}}
\makeatletter
\newenvironment{kframe}{%
\medskip{}
\setlength{\fboxsep}{.8em}
\def\at@end@of@kframe{}%
\ifinner\ifhmode%
\def\at@end@of@kframe{\end{minipage}}%
\begin{minipage}{\columnwidth}%
\fi\fi%
\def\FrameCommand##1{\hskip\@totalleftmargin \hskip-\fboxsep
\colorbox{shadecolor}{##1}\hskip-\fboxsep
% There is no \\@totalrightmargin, so:
\hskip-\linewidth \hskip-\@totalleftmargin \hskip\columnwidth}%
\MakeFramed {\advance\hsize-\width
\@totalleftmargin\z@ \linewidth\hsize
\@setminipage}}%
{\par\unskip\endMakeFramed%
\at@end@of@kframe}
\makeatother
\renewenvironment{Shaded}{\begin{kframe}}{\end{kframe}}
\usepackage{makeidx}
\makeindex
\usepackage[small,firstabbrev]{authorindex}
\aimaxauthors{5} % maximum number of authors to index
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Index generation
% Indexentry for a word/phrase (Word inserted into the text)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\newcommand{\IX}[1]{\index{#1}#1}
\newcommand{\ix}[1]{\index{#1}}
\newcommand{\ixmain}[1]{\index{#1|textbf}}
\newcommand{\ixon}[1]{\index{#1|(}}
\newcommand{\ixoff}[1]{\index{#1|)}}
% R functions
\newcommand{\ixfunc}[1]{%
\index{#1@\texttt{#1()}}%
}
% R packages: indexed under both package name and packages!
\newcommand{\ixp}[1]{%
\index{#1@\textsf{#1} package}%
\index{package!#1@\textsf{#1}}%
}
% data sets:
\newcommand{\ixd}[1]{%
\index{datasets!@\texttt{#1}}
\index{@\texttt{#1} dataset}
}
\urlstyle{tt}
\usepackage{amsthm}
\makeatletter
\def\thm@space@setup{%
\thm@preskip=8pt plus 2pt minus 4pt
\thm@postskip=\thm@preskip
}
\makeatother
\frontmatter
\makeatletter
\@ifpackageloaded{tcolorbox}{}{\usepackage[skins,breakable]{tcolorbox}}
\@ifpackageloaded{fontawesome5}{}{\usepackage{fontawesome5}}
\definecolor{quarto-callout-color}{HTML}{909090}
\definecolor{quarto-callout-note-color}{HTML}{0758E5}
\definecolor{quarto-callout-important-color}{HTML}{CC1914}
\definecolor{quarto-callout-warning-color}{HTML}{EB9113}
\definecolor{quarto-callout-tip-color}{HTML}{00A047}
\definecolor{quarto-callout-caution-color}{HTML}{FC5300}
\definecolor{quarto-callout-color-frame}{HTML}{acacac}
\definecolor{quarto-callout-note-color-frame}{HTML}{4582ec}
\definecolor{quarto-callout-important-color-frame}{HTML}{d9534f}
\definecolor{quarto-callout-warning-color-frame}{HTML}{f0ad4e}
\definecolor{quarto-callout-tip-color-frame}{HTML}{02b875}
\definecolor{quarto-callout-caution-color-frame}{HTML}{fd7e14}
\makeatother
\makeatletter
\@ifpackageloaded{bookmark}{}{\usepackage{bookmark}}
\makeatother
\makeatletter
\@ifpackageloaded{caption}{}{\usepackage{caption}}
\AtBeginDocument{%
\ifdefined\contentsname
\renewcommand*\contentsname{Table of contents}
\else
\newcommand\contentsname{Table of contents}
\fi
\ifdefined\listfigurename
\renewcommand*\listfigurename{List of Figures}
\else
\newcommand\listfigurename{List of Figures}
\fi
\ifdefined\listtablename
\renewcommand*\listtablename{List of Tables}
\else
\newcommand\listtablename{List of Tables}
\fi
\ifdefined\figurename
\renewcommand*\figurename{Figure}
\else
\newcommand\figurename{Figure}
\fi
\ifdefined\tablename
\renewcommand*\tablename{Table}
\else
\newcommand\tablename{Table}
\fi
}
\@ifpackageloaded{float}{}{\usepackage{float}}
\floatstyle{ruled}
\@ifundefined{c@chapter}{\newfloat{codelisting}{h}{lop}}{\newfloat{codelisting}{h}{lop}[chapter]}
\floatname{codelisting}{Listing}
\newcommand*\listoflistings{\listof{codelisting}{List of Listings}}
\makeatother
\makeatletter
\makeatother
\makeatletter
\@ifpackageloaded{caption}{}{\usepackage{caption}}
\@ifpackageloaded{subcaption}{}{\usepackage{subcaption}}
\makeatother
\makeatletter
\@ifpackageloaded{tcolorbox}{}{\usepackage[skins,breakable]{tcolorbox}}
\makeatother
\makeatletter
\@ifundefined{shadecolor}{\definecolor{shadecolor}{rgb}{.97, .97, .97}}{}
\makeatother
\makeatletter
\@ifundefined{codebgcolor}{\definecolor{codebgcolor}{HTML}{E8FFFF}}{}
\makeatother
\makeatletter
\ifdefined\Shaded\renewenvironment{Shaded}{\begin{tcolorbox}[enhanced, sharp corners, breakable, frame hidden, colback={codebgcolor}, boxrule=0pt]}{\end{tcolorbox}}\fi
\makeatother
\makeatletter
\@ifpackageloaded{sidenotes}{}{\usepackage{sidenotes}}
\@ifpackageloaded{marginnote}{}{\usepackage{marginnote}}
\makeatother
\ifLuaTeX
\usepackage{selnolig} % disable illegal ligatures
\fi
\usepackage{bookmark}
\IfFileExists{xurl.sty}{\usepackage{xurl}}{} % add URL line breaks if available
\urlstyle{same} % disable monospaced font for URLs
\hypersetup{
pdftitle={Visualizing Multivariate Data and Models in R},
pdfauthor={Michael Friendly},
colorlinks=true,
linkcolor={blue},
filecolor={Maroon},
citecolor={Blue},
urlcolor={Blue},
pdfcreator={LaTeX via pandoc}}
\title{Visualizing Multivariate Data and Models in R}
\author{Michael Friendly}
\date{2024-10-21}
\begin{document}
\maketitle
% you may need to leave a few empty pages before the dedication page
%\cleardoublepage\newpage\thispagestyle{empty}\null
%\cleardoublepage\newpage\thispagestyle{empty}\null
%\cleardoublepage\newpage
\thispagestyle{empty}
\begin{center}
Here is where the dedication goes ...
%\includegraphics{images/dedication.pdf}
\end{center}
\setlength{\abovedisplayskip}{-5pt}
\setlength{\abovedisplayshortskip}{-5pt}
% Define needed colors for xcolor
\definecolor{darkgreen}{RGB}{1,50,32}
\renewcommand*\contentsname{Table of contents}
{
\hypersetup{linkcolor=}
\setcounter{tocdepth}{2}
\tableofcontents
}
\bookmarksetup{startatroot}
\chapter*{Preface}\label{preface}
\addcontentsline{toc}{chapter}{Preface}
\markboth{Preface}{Preface}
\textbf{TODO}: Make this a more general introduction
This book is about graphical methods developed recently for multivariate
data, and their uses in understanding relationships when there are
several aspects to be considered together. Data visualization methods
for statistical analysis are well-developed for simple linear models
with a single outcome variable. However, with applied research in the
social and behavioral sciences, it is often the case that the phenomena
of interest (e.g., depression, job satisfaction, academic achievement,
childhood ADHD disorders, etc.) can be measured in several different
ways or related aspects.
For example, if academic achievement can be measured for adolescents by
reading, mathematics, science and history scores, how do predictors such
as parental encouragement, school environment and socioeconomic status
affect all these outcomes? In a similar way? In different ways? In such
cases, much more can be understood from a multivariate approach that
considers the correlations among the outcomes. Yet, sadly, researchers
typically examine the outcomes one by one which often only tells part of
the data story.
However, to do this it is useful to set the stage for multivariate
thinking, with a grand scheme for statistics and data visualization, a
parable, and an example of multivariate discovery.
\section*{ONE, TWO, MANY}\label{one-two-many}
\addcontentsline{toc}{section}{ONE, TWO, MANY}
\markright{ONE, TWO, MANY}
There is an old and helpful idea I learned from John Hartigan in my
graduate days at Princeton:
\begin{quote}
In statistics and data visualization \emph{all} methods can be
classified by the number of dimensions contemplated, on a scale of
\textbf{ONE}, \textbf{TWO}, \textbf{MANY}.
\end{quote}
By this, he meant that, at a global level, all data, statistical
summaries, and graphical displays could be classified as:
\begin{itemize}
\tightlist
\item
\textbf{univariate}: a single variable, considered in isolation (age,
COVID cases, pizzas ordered). Univariate numerical summaries are
means, medians, measures of variablilty, and so forth. Univariate
displays include dot plots, boxplots, histograms and density
estimates.
\item
\textbf{bivariate}: two variables, considered jointly. Numerical
summaries include correlations, covariances and two-way tables of
frequencies or measures of association for categorical variables.
Bivariate displays include scatterplots and mosaic plots.
\item
\textbf{multivariate}: three or more variables, considered jointly.
Numerical summaries include correlation and covariance matrices,
consisting of all pairwise values, but also derived measures from the
analysis of these matrices (eigenvalues, eigenvectors). Graphical
displays of multivariate data can sometimes be shown in 3D, but often
involve multiple views of the data projected into 2D plots.
\end{itemize}
As a quasi-numerical scale, I refer to these as \textbf{1D}, \textbf{2D}
and \textbf{nD}. This admits the possibility of half-integer cases, such
as \textbf{1.5D}, where the main focus is on a single variable, but that
is classified by a simple factor (e.g., gender), or \textbf{2.5D} where
a 2D scatterplot can show other variables using color, shape or other
visual attributes His point in this classification was that once you've
reached three variables, all higher dimensions involve similar summaries
and data displays.
Univariate and bivariate methods and displays are well-known. This book
is about how these ideas can be extended to an \(n\)-dimensional world.
Three-dimensional data displays are now fairly easy to produce, even if
they are sometimes difficult to understand. But how can we even think
about four or more dimensions? The difficulty can be appreciated by
considering the tale of \emph{Flatland}.
\section*{Flatland}\label{flatland}
\addcontentsline{toc}{section}{Flatland}
\markright{Flatland}
\begin{quote}
To comport oneself with perfect propriety in Polygonal society, one
ought to be a Polygon oneself. --- Edwin A. Abbott, \emph{Flatland}
\end{quote}
In 1884, an English schoolmaster, Edwin Abbott Abbott, shook the world
of Victorian culture with a slim volume, \emph{Flatland: A Romance of
Many Dimensions} (\citeproc{ref-Abbott:1884}{Abbott, 1884}). He
described a two-dimensional world, \emph{Flatland}, inhabited entirely
by geometric figures in the plane. His purpose was satirical, to poke
fun at the social and gender class system at the time: Women were mere
line segments, while men were represented as polygons with varying
numbers of sides--- a triangle was a working man, but acute isosceles
were soldiers or criminals of very small angle; gentlemen and
professionals had more sides. Abbot published this under the pseudonym,
``A Square'', suggesting his place in the hierarchy.
\begin{quote}
True, said the Sphere; it appears to you a Plane, because you are not
accustomed to light and shade and perspective; just as in Flatland a
Hexagon would appear a Straight Line to one who has not the Art of Sight
Recognition. But in reality it is a Solid, as you shall learn by the
sense of Feeling. --- Edwin A. Abbott, \emph{Flatland}
\end{quote}
But how did it feel to be a member of a flatland society? How could a
point (a newborn child?) understand a line (a woman)? How does a
Triangle ``see'' a Hexagon or even a infinitely-sided Circle? Abbott
introduces the very idea of different dimensions of existence through
dreams and visions:
\begin{itemize}
\item
A Square dreams of visiting a one-dimensional \emph{Lineland} where
men appear as lines, and women are merely ``illustrious points'', but
the inhabitants can only see the Square as lines.
\item
In a vision, the Square is visited by a Sphere, to illustrate what a
2D Flatlander could understand from a 3D sphere
(Figure~\ref{fig-flatland-spheres}) that passes through the plane he
inhabits. It is a large circle when seen at the moment of its'
greatest extent. As the Spehere rises, it becomes progressively
smaller, until it becomes a point, and then vanishes.
\end{itemize}
\begin{figure}
\centering{
\includegraphics[width=0.9\textwidth,height=\textheight]{images/flatland-spheres.jpg}
}
\caption{\label{fig-flatland-spheres}A 2D Flatlander seeing a sphere as
it passes through Flatland. The line, labeled `My Eye' indicates what
the Flatlander would see. Source: Abbott
(\citeproc{ref-Abbott:1884}{1884})}
\end{figure}%
Abbott goes on to state what could be considered as a demonstration (or
proof) by induction of the difficulties of seeing in 1, 2, 3 dimensions,
and how the idea motion over time (one more dimension) could allow
citizens of any 1D, 2D, 3D world to contemplate one more dimension.
\begin{quote}
In One Dimensions, did not a moving Point produce a Line with two
terminal points? In two Dimensions, did not a moving Line produce a
Square with four terminal points? In Three Dimensions, did not a moving
Square produce - did not the eyes of mine behold it - that blessed
being, a Cube, with eight terminal points? And in Four Dimensions, shall
not a moving Cube - alas, for Analogy, and alas for the Progress of
Truth if it be not so - shall not, I say the motion of a divine Cube
result in a still more divine organization with sixteen terminal points?
--- Edwin A. Abbott
\end{quote}
For Abbot, the way for a citizen of any world to imagine one more
dimension was to consider how a higher-dimensional object would change
over time.\footnote{In his famous TV series, \emph{Cosmos}, Carl Sagan
provides \href{https://youtu.be/UnURElCzGc0}{an intriguing video
presentation} Flatland and the 4th dimension. However, as far back as
1754 (\citeproc{ref-Cajori:1926}{Cajori, 1926}), the idea of adding a
fourth dimension appears in Jean le Rond d'Alembert's ``Dimensions'',
and one realization of a four-dimensional object is a
\emph{tesseract}, shown in Figure~\ref{fig-1D-4D}.} A line moved over
time could produce a rectangle as shown in Figure~\ref{fig-1D-4D}; that
rectangle moving in another direction over time would produce a 3D
figure, and so forth.
\begin{figure}
\centering{
\includegraphics[width=0.9\textwidth,height=\textheight]{images/1D-4D.png}
}
\caption{\label{fig-1D-4D}Geometrical objects in 1 to 4 dimensions. One
more dimension can be thought of as the trace of movement over time.}
\end{figure}%
But wait! Where does that 4D thing (a \emph{tesseract}) come from? To
really see a tesseract it helps to view it in an animation over time
(\textbf{?@fig-tesseract}). But like the Square, contemplating 3D from a
2D world, it takes some imagination.
Yet the deep mathematics of more than three dimensions only emerged in
the 19th century. In Newtonian mechanics, space and time were always
considered independent of each other. Our familiar three-dimensional
space, of length, width, and height had formed the backbone of Euclidean
geometry for millenea. However, the idea that space and time are indeed
interwoven was first proposed by German mathematician Hermann Minkowski
(1864--1909) in 1908. This was a powerful idea. It bore fruit when
Albert Einstein revolutionized the Newtonian conceptions of gravity in
1915 when he presented a theory of general relativity which was based
primarily on the fact that mass and energy warp the fabric of
four-dimensional spacetime.
The parable of \emph{Flatland} can provide inspiration for statistical
thinking and data visualization. Once we go beyond bivariate statistics
and 2D plots, we are in a multivariate world of possibly MANY
dimensions. It takes only some imagination and suitable methods to get
there.
Like Abbott's \emph{Flatland}, this book is a romance, in many
dimensions, of what we can learn from modern methods of data
visualization.
\section*{EUREKA!}\label{eureka}
\addcontentsline{toc}{section}{EUREKA!}
\markright{EUREKA!}
Even modest sized multivariate data can have secrets that can be
revealed in the right view. As an example, David Coleman at RCA
Laboratories in Princeton, N.J. generated a dataset of five (fictitious)
measurements of grains of pollen for the 1986 Data Exposition at the
Joint statistical Meetings. The first three variables are the lengths of
geometric features 3848 observed sampled pollen grains -- in the x, y,
and z dimensions: a \texttt{ridge} along x, a \texttt{nub} in the y
direction, and a \texttt{crack} in along the z dimension. The fourth
variable is pollen grain \texttt{weight}, and the fifth is
\texttt{density}. The challenge was to ``find something interesting'' in
this dataset, now available as \texttt{animation::pollen}. \ixd{pollen}
\ixp{animation}
Those who solved the puzzle were able to find an orientation of this
5-dimensional dataset, such that zooming in revealed a magic word,
``EUREKA'' spelled in points, as in the following figure.
\begin{figure}
\begin{minipage}{0.50\linewidth}
\includegraphics[width=0.4\textwidth,height=\textheight]{images/pollen-eureka1.png}\end{minipage}%
%
\begin{minipage}{0.50\linewidth}
\includegraphics[width=0.4\textwidth,height=\textheight]{images/pollen-eureka2.png}\end{minipage}%
\newline
\begin{minipage}{0.50\linewidth}
\includegraphics[width=0.4\textwidth,height=\textheight]{images/pollen-eureka4.png}\end{minipage}%
%
\begin{minipage}{0.50\linewidth}
\includegraphics[width=0.4\textwidth,height=\textheight]{images/pollen-eureka3.png}\end{minipage}%
\caption{\label{fig-pollen-eureka}Four views of the \texttt{pollen}
data, zooming in, clockwise from the upper left to discover the word
``EUREKA''.}
\end{figure}%
The path to finding the hidden word can be seen better in a 3D
animation. The online version of the book uses The \texttt{rgl} package
(\citeproc{ref-R-rgl}{Adler \& Murdoch, 2023}) create a 3D scatterplot
of the first three variables. Then the \texttt{animation} package
(\citeproc{ref-R-animation}{Xie, 2021}) is use to record a sequence of
images, adjusting the \texttt{rgl::par3d(zoom)} value. \ixp{rgl}
\ixp{animation}
\subsection*{Multivariate scientific discoveries}\label{sec-discoveries}
\addcontentsline{toc}{subsection}{Multivariate scientific discoveries}
Lest this example seem contrived (which it admittedly is), multivariate
visualization has played an important role in quite a few scientific
discoveries. Among these, Francis Galton's
(\citeproc{ref-Galton:1863}{1863}) discovery of the anti-cyclonic
pattern of wind direction in relation to barometric pressure from many
weather measures recorded systematically across all weather stations,
lighthouses and observatories in Europe in December 1861 stands out as
the best example of a scientific discovery achieved almost entirely
through graphical means---- something that was totally unexpected, and
purely the product of his use of remarkably novel high-dimensional
graphs (\citeproc{ref-FriendlyWainer:2021:TOGS}{Friendly \& Wainer,
2021, pp. 170--173}).
A more recent example is the discovery of two general classes in the
development of Type 2 diabetes by Reaven \& Miller
(\citeproc{ref-ReavenMiller:79}{1979}), using PRIM-9
(\citeproc{ref-Fishkeller-etal:1974b}{Fishkeller et al., 1974}), the
first computer system for high-dimensional visualization\footnote{PRIM-9
is an acronym for \textbf{P}icturing, \textbf{R}otation,
\textbf{I}solation and \textbf{M}asking in up to \textbf{9}
dimensions. These operations are fundamental to interactive and
dynamic data visualization.}. In an earlier study Reaven \& Miller
(\citeproc{ref-ReavenMiller:68}{1968}) examined the relation between
blood glucose levels and the production of insulin in normal subjects
and in patients with varying degrees of hyperglicemia (elevated blood
sugar level). They found a peculiar `'horse shoe'' shape in this
relation (shown in Figure~\ref{fig-diabetes1}), about which they could
only speculate: perhaps individuals with the best glucose tolerance also
had the lowest levels of insulin as a response to an oral dose of
glucose; perhaps those with low glucose response could secrete higher
levels of insulin; perhaps those who were low on both glucose and
insulin responses followed some other mechanism. In 2D plots, this was a
mystery.
\begin{Shaded}
\begin{Highlighting}[]
\FunctionTok{data}\NormalTok{(Diabetes, }\AttributeTok{package=}\StringTok{"heplots"}\NormalTok{)}
\FunctionTok{plot}\NormalTok{(instest }\SpecialCharTok{\textasciitilde{}}\NormalTok{ glutest, }\AttributeTok{data=}\NormalTok{Diabetes, }
\AttributeTok{pch=}\DecValTok{16}\NormalTok{,}
\AttributeTok{cex.lab=}\FloatTok{1.25}\NormalTok{,}
\AttributeTok{xlab=}\StringTok{"Glucose response"}\NormalTok{,}
\AttributeTok{ylab=}\StringTok{"Insulin response"}\NormalTok{)}
\end{Highlighting}
\end{Shaded}
\begin{figure}
\centering{
\includegraphics[width=0.7\textwidth,height=\textheight]{figs/fig-diabetes1-1.pdf}
}
\caption{\label{fig-diabetes1}Reproduction of a graph similar to that
from Reaven \& Miller (\citeproc{ref-ReavenMiller:68}{1968}) on the
relationship between glucose and insulin response to being given an oral
dose of glucose.}
\end{figure}%
An answer to their questions came ten years later, when they were able
to visualize similar but new data in 3D using the PRIM-9 system. In a
carefully controlled study, they also measured `'steady state plasma
glucose'' (SSPG), a measure of the efficiency of use of insulin in the
body, where large values mean insulin resistance, as well as other
variables. PRIM-9 allowed them to explore various sets of three
variables, and, more importantly, to rotate a given plot in three
dimensions to search for interesting features. One plot that stood out
concerned the relation between plasma glucose response, plasma insulin
response and SSPG response, shown in Figure~\ref{fig-ReavenMiller-3d}.
\begin{figure}
\centering{
\includegraphics[width=0.7\textwidth,height=\textheight]{images/ReavenMiller-3d-annotated.png}
}
\caption{\label{fig-ReavenMiller-3d}Artist's rendition of data from
Reaven \& Miller (\citeproc{ref-ReavenMiller:79}{1979}) as seen in three
dimensions using the PRIM-9 system. Labels for the clusters have been
added, identifying the three groups of patients. \emph{Source}: Reaven
\& Miller (\citeproc{ref-ReavenMiller:79}{1979}).}
\end{figure}%
From this graphical insight, they were able to classify the participants
into three groups, based on clinical levels of glucose and insulin. The
people in the wing on the left in Figure~\ref{fig-ReavenMiller-3d} were
considered to have overt diabetes, the most advanced form, characterized
by elevated fasting blood glucose concentration and classical diabetic
symptoms. Those in the right wing were classified as latent or chemical
diabetics, with no symptoms of diabetes but demonstrable abnormality of
oral or intravenous glucose tolerance. Those in the central blob were
classified as normal.
Previous thinking was that Type 2 diabetes (when the body cannot make
\emph{enough} insulin, as opposed to Type I, an autoimmune condition
where the pancreatic cells have been destroyed) progressed from the
chemical stage to an overt one in a smooth transition. However, it was
clear from Figure~\ref{fig-ReavenMiller-3d} that the only ``path'' from
one to the other lead through the cluster of normal patients near the
origin, so that explanation must be wrong. Instead, this suggested that
the chemical and overt diabetics were distinct classes. Indeed,
longitudinal studies showed that patients classified as chemical
diabetics rarely developed the overt form. The understanding of the
etiology of Type 2 diabetes was altered dramatically by the power of
high-D interactive graphics.
\section*{What I assume}\label{what-i-assume}
\addcontentsline{toc}{section}{What I assume}
\markright{What I assume}
It is assumed that the reader has a background in applied
\emph{intermediate} statistics including material on univariate linear
models including analysis of variance (ANOVA) and multiple regression.
This means you should be familiar with \ldots{} \textbf{TODO}: Complete
this required background
There will also be some mathematics in the book where words and diagrams
are not enough. The mathematical level will be intermediate, mostly
consisting of simple algebra. No derivations, proofs, theorems here! For
multivariate methods, it will be useful to express ideas using matrix
notation to simplify presentation. The single symbol I'm using math to
express ideas, and all you will need is a reading-level of
understanding. For this, the first chapter of Fox
(\citeproc{ref-Fox2021}{2021}), \emph{A mathematical primer for social
statistics}, is excellent. If you want to learn something of using
matrix algebra for data analysis and statistics, I recommend our package
\texttt{matlib} (\citeproc{ref-R-matlib}{Friendly et al., 2024}).
I also assume the reader to have at least a basic familiarity with R.
While R fundamentals are outside the scope of the book, I believe that
this language provides a rich set of resources, far beyond that offered
by other statistical software packages, and is well worth learning.
For those not familiar with R, I recommend Matloff
(\citeproc{ref-Matloff-2011}{2011}), Wickham
(\citeproc{ref-Wickham2014}{2014}), and Cotton
(\citeproc{ref-Cotton-2013}{2013}) for introductions to programming in
the language. Fox \& Weisberg (\citeproc{ref-FoxWeisberg:2018}{2018a})
and Teetor (\citeproc{ref-Teetor2011}{2011}) are great for learning
about how to conduct basic statistical analyses in R. \textbf{TODO}:
Revise this list.
\section*{Conventions used in this
book}\label{conventions-used-in-this-book}
\addcontentsline{toc}{section}{Conventions used in this book}
\markright{Conventions used in this book}
The following typographic conventions are used in this book:
\begin{itemize}
\item
\emph{italic} : indicates terms to be \emph{emphasized} or defined in
the text, \ldots{}
\item
\textbf{bold} : is used for names of R packages. Or, better yet:
\textbf{\texttt{bold\ monospace}}, but I'd rather this be in a
\textcolor{darkgreen}{different color}. Perhaps I can use ``r
colorize(''\textbf{lattice}'', ``green'')'' inline -\textgreater{}
\textcolor{green}{**lattice**} will do this? This does bold \& color,
but can't use monospace.
I can now use inline `pkg(``lattice'')' generating \texttt{lattice},
or also with a citation, \texttt{pkg("lattice",\ cite=TRUE)}
-\textgreater{} \texttt{lattice} (\citeproc{ref-R-lattice}{Sarkar,
2024}), but can't do color or monospace with this.
\item
\texttt{fixed-width} : is used in program listings as well as in text
to refer to variable and function names, R statement elements and
keywords.
\item
R code in program listings and output is presented in
\texttt{monospaced\ (typewriter)} font,
\href{https://fonts.google.com/specimen/Fira+Mono}{\texttt{fira\ mono}}
\item
\emph{\texttt{fixed-width\ italic}} : isn't used yet, but probably
should be.
\end{itemize}
For R functions in packages, we use the notation
\texttt{package::function()}, for example: \texttt{car::Anova()} to
identify where those functions are defined
\mainmatter
\part{Orienting Ideas}
\chapter{Introduction}\label{sec-introduction}
This material may or may not survive; it was taken from an earlier
article.
\section{Multivariate vs.~multivariable
methods}\label{multivariate-vs.-multivariable-methods}
\begin{quote}
multivariate \(\ne\) multivariable
\end{quote}
In this era of multivitamins, multitools, multifactor authentication and
even the multiverse, it is well to understand the distinction between
\emph{multivariate} and \emph{multivariable} methods as these terms are
generally used and as I use them here in relation to statistical methods
and data visualization. The distinction is simple:
\begin{itemize}
\item
\textbf{Multivariate methods} for linear models such as multivariate
regression have more than one dependent, response or outcome variable.
Other multivariate methods such as principal components analysis or
factor analysis treat all variables on an equal footing.
\item
\textbf{Multivariable methods} have a single dependent variable and
more than one independent variables or covariates.
\end{itemize}
\section{Why use a multivariate
design}\label{why-use-a-multivariate-design}
A particular research outcome (e.g., depression, neuro-cognitive
functioning, academic achievement, self-concept, attention deficit
hyperactivity disorders) might take on a multivariate form if it has
several observed measurement scales or related aspects by which it is
quantified, or if there are multiple theoretically distinct outcomes
that should be assessed in conjunction with each other (e.g., using
depression, generalized anxiety, and stress inventories to model overall
happiness). In this situation, the primary concern of the researcher is
to ascertain the impact of potential predictors on two or more response
variables simultaneously.
For example, if academic achievement is measured for adolescents by
their reading, mathematics, science, and history scores, the following
questions are of interest:
\begin{itemize}
\item
Do predictors such as parent encouragement, socioeconomic status and
school environmental variables affect \emph{all} of these outcomes?
\item
Do they affect them in the \emph{same} or \emph{different} ways?
\item
How many different aspects of academic achievement can be
distinguished in the predictors? Equivalently, is academic achievement
\emph{unidimensional} or \emph{multidimensional} in relation to the
predictors?
\end{itemize}
Similarly, if psychiatric patients in various diagnostic categories are
measured on a battery of tests related to social skills and cognitive
functioning, we might want to know:
\begin{itemize}
\item
Which measures best discriminate among the diagnostic groups?
\item
Which measures are most predictive of positive outcomes?
\item
Further, how are the \emph{relationships} between the outcomes
affected by the predictors?
\end{itemize}
Such questions obviously concern more than just the separate univariate
relations of each response to the predictors. Equally, or perhaps more
importantly, are questions of how the response variables are predicted
\emph{jointly}.
\begin{tcolorbox}[enhanced jigsaw, titlerule=0mm, leftrule=.75mm, breakable, toprule=.15mm, toptitle=1mm, colframe=quarto-callout-note-color-frame, arc=.35mm, colback=white, colbacktitle=quarto-callout-note-color!10!white, opacityback=0, rightrule=.15mm, coltitle=black, opacitybacktitle=0.6, bottomtitle=1mm, title=\textcolor{quarto-callout-note-color}{\faInfo}\hspace{0.5em}{SEM}, bottomrule=.15mm, left=2mm]
Structural equation modeling (SEM) offers another route to explore and
analyze the relationships among multiple predictors and multiple
responses. They have the advantage of being able to test potentially
complex systems of linear equations in very flexible ways; however,
these methods are often far removed from data analysis \emph{per se} and
except for path diagrams offer little in the way of visualization
methods to aid in understanding and communicating the results. The
graphical methods we describe here can also be useful in a SEM context.
\ix{Structural equation model}
\end{tcolorbox}
\section{Linear models: Univariate to
multivariate}\label{linear-models-univariate-to-multivariate}
For classical linear models for ANOVA and regression, the step from a
univariate model for a single response, \(y\), to a multivariate one for
a collection of \(p\) responses, \(\mathbf{y}\) is conceptually very
easy. That's because the univariate model,
\[y_i = \beta_0 + \beta_1 x_1 + \beta_2 x_2 + \dots + \beta_q x_q + \epsilon_i , \]
or, in matrix terms,
\[\mathbf{y} = \mathbf{X} \; \mathbf{\beta} + \mathbf{\epsilon}, \quad\mbox{ with }\quad \mathbf{u} \sim \mathcal{N} (0, \sigma^2 \mathbf{I}) ,\]
generalizes directly to an analogous multivariate linear model (MLM),
\[\mathbf{Y} = [\mathbf{y_1}, \mathbf{y_2}, \dots, \mathbf{y_p}] = \mathbf{X} \; \mathbf{B} + \Epsilon \quad\mbox{ with }\quad \Epsilon \sim \mathcal{N} (\mathbf{0}, \mathbf{\Sigma})\]
for multiple responses (as will be discussed in detail). The design
matrix, \(\mathbf{X}\) remains the same, and the vector \(\beta\) of
coefficients becomes a matrix \(\mathbf{B}\), with one column for each
of the \(p\) outcome variables.
Happily as well, hypothesis tests for the MLM are also straight-forward
generalizations of the familiar \(F\) and \(t\)-tests for univariate
response models. Moreover, there is a rich geometry underlying these
generalizations which we can exploit for understanding and
visualization.
\section{Visualization is harder}\label{visualization-is-harder}
However, with two or more response variables, visualizations for
multivariate models are not as simple as they are for their univariate
counterparts for understanding the effects of predictors, model
parameters, or model diagnostics. Consequently, the results of such
studies are often explored and discussed solely in terms of coefficients
and significance, and visualizations of the relationships are only
provided for one response variable at a time, if at all. This tradition
can mask important nuances, and lead researchers to draw erroneous
conclusions.
The aim of this book is to describe and illustrate some central methods
that we have developed over the last ten years that aid in the
understanding and communication of the results of multivariate linear
models (\citeproc{ref-Friendly-07-manova}{Friendly, 2007};
\citeproc{ref-FriendlyMeyer:2016:DDAR}{Friendly \& Meyer, 2016}). These
methods rely on \emph{data ellipsoids} as simple, minimally sufficient
visualizations of variance that can be shown in 2D and 3D plots. As will
be demonstrated, the \emph{Hypothesis-Error (HE) plot} framework applies
this idea to the results of multivariate tests of linear hypotheses.
\ix{data ellipse} \ix{HE plot}
Further, in the case where there are more than just a few outcome
variables, the important nectar of their relationships to predictors can
often be distilled in a multivariate juicer--- a \textbf{projection} of
the multivariate relationships to the predictors in the low-D space that
captures most of the flavor. This idea can be applied using
\emph{canonical correlation plots} and with \emph{canonical discriminant
HE plots}. \ix{canonical correlation} \ix{projection}
\begin{figure}[H]
{\centering \includegraphics{images/Cover-GBE.png}