100% found this document useful (6 votes)
90 views

(PDF Download) Using R and RStudio For Data Management Statistical Analysis and Graphics 2nd Edition Nicholas J. Horton Fulll Chapter

The document discusses a book about using R and RStudio for data management, statistical analysis, and graphics. It provides details on the second edition such as new chapters on case studies, maps, web scraping, text mining, and simulation. It also discusses new R packages and reorganized content.

Uploaded by

yustanseegun
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (6 votes)
90 views

(PDF Download) Using R and RStudio For Data Management Statistical Analysis and Graphics 2nd Edition Nicholas J. Horton Fulll Chapter

The document discusses a book about using R and RStudio for data management, statistical analysis, and graphics. It provides details on the second edition such as new chapters on case studies, maps, web scraping, text mining, and simulation. It also discusses new R packages and reorganized content.

Uploaded by

yustanseegun
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 49

Download and Read online, DOWNLOAD EBOOK, [PDF EBOOK EPUB ], Ebooks

download, Read Ebook EPUB/KINDE, Download Book Format PDF

Using R and RStudio for Data Management


Statistical Analysis and Graphics 2nd Edition
Nicholas J. Horton

OR CLICK LINK
https://textbookfull.com/product/using-r-and-
rstudio-for-data-management-statistical-analysis-
and-graphics-2nd-edition-nicholas-j-horton/

Read with Our Free App Audiobook Free Format PFD EBook, Ebooks dowload PDF
with Andible trial, Real book, online, KINDLE , Download[PDF] and Read and Read
Read book Format PDF Ebook, Dowload online, Read book Format PDF Ebook,
[PDF] and Real ONLINE Dowload [PDF] and Real ONLINE
More products digital (pdf, epub, mobi) instant
download maybe you interests ...

R Cookbook Proven Recipes for Data Analysis Statistics


and Graphics Jd Long

https://textbookfull.com/product/r-cookbook-proven-recipes-for-
data-analysis-statistics-and-graphics-jd-long/

R in Action Data Analysis and Graphics with R Bonus ch


23 ONLY 2nd Edition Robert Kabacoff

https://textbookfull.com/product/r-in-action-data-analysis-and-
graphics-with-r-bonus-ch-23-only-2nd-edition-robert-kabacoff/

Statistical Data Analysis using SAS Intermediate


Statistical Methods Mervyn G. Marasinghe

https://textbookfull.com/product/statistical-data-analysis-using-
sas-intermediate-statistical-methods-mervyn-g-marasinghe/

Visualizing Data in R 4 Graphics Using the base


graphics stats and ggplot2 Packages 1st Edition Margot
Tollefson

https://textbookfull.com/product/visualizing-data-
in-r-4-graphics-using-the-base-graphics-stats-and-
ggplot2-packages-1st-edition-margot-tollefson/
R Graphics Cookbook Practical Recipes for Visualizing
Data 2nd Edition Winston Chang

https://textbookfull.com/product/r-graphics-cookbook-practical-
recipes-for-visualizing-data-2nd-edition-winston-chang/

Metaprogramming in R: Advanced Statistical Programming


for Data Science, Analysis and Finance 1st Edition
Thomas Mailund

https://textbookfull.com/product/metaprogramming-in-r-advanced-
statistical-programming-for-data-science-analysis-and-
finance-1st-edition-thomas-mailund/

An Introduction to Statistical Methods and Data


Analysis 7th Edition R. Lyman Ott

https://textbookfull.com/product/an-introduction-to-statistical-
methods-and-data-analysis-7th-edition-r-lyman-ott/

Statistical and Thermal Physics An Introduction 2nd


Edition Michael J R Hoch

https://textbookfull.com/product/statistical-and-thermal-physics-
an-introduction-2nd-edition-michael-j-r-hoch/

Functional Programming in R: Advanced Statistical


Programming for Data Science, Analysis and Finance 1st
Edition Thomas Mailund

https://textbookfull.com/product/functional-programming-in-r-
advanced-statistical-programming-for-data-science-analysis-and-
finance-1st-edition-thomas-mailund/
Statistics
Second
Edition
Incorporating the latest R packages as well as new case studies and applica-
tions, Using R and RStudio for Data Management, Statistical Analysis, and

Statistical Analysis, and Graphics


Using R and RStudio for Data Management,
Graphics, Second Edition covers the aspects of R most often used by statisti-
cal analysts. New users of R will find the book’s simple approach easy to under-
stand while more sophisticated users will appreciate the invaluable source of
task-oriented information.
New to the Second Edition
• The use of RStudio, which increases the productivity of R users and helps
users avoid error-prone cut-and-paste workflows
• New chapter of case studies illustrating examples of useful data
management tasks, reading complex files, making and annotating maps,
“scraping” data from the web, mining text files, and generating dynamic
graphics
• New chapter on special topics that describes key features, such as
processing by group, and explores important areas of statistics, including
Bayesian methods, propensity scores, and bootstrapping
• New chapter on simulation that includes examples of data generated from
complex models and distributions
• A detailed discussion of the philosophy and use of the knitr and markdown
packages for R
• New packages that extend the functionality of R and facilitate sophisticated
analyses
• Reorganized and enhanced chapters on data input and output, data
management, statistical and mathematical functions, programming, high-
level graphics plots, and the customization of plots
Conveniently organized by short, clear descriptive entries, this edition continues
to show users how to easily perform an analytical task in R. Users can quickly

Horton and Kleinman


find and implement the material they need through the extensive indexing, cross-
referencing, and worked examples in the text. Datasets and code are available
for download on a supplementary website.

K23166
Nicholas J. Horton and Ken Kleinman

w w w. c rc p r e s s . c o m

K23166_cover.indd 1 2/3/15 12:39 PM


i i

“K23166” — 2015/1/28 — 9:35 — page 2 — #2


i i

Using R and
RStudio
for Data Management,
Statistical Analysis,
and Graphics
Second Edition

i i

i i
i i

“K23166” — 2015/1/28 — 9:35 — page 3 — #3


i i

i i

i i
i i

“K23166” — 2015/1/28 — 9:35 — page 4 — #4


i i

R and
Using
RStudio
for Data Management,
Statistical Analysis,
and Graphics
Second Edition

Nicholas J. Horton
Department of Mathematics and Statistics
Amherst College
Massachusetts, U.S.A.

Ken Kleinman
Department of Population Medicine
Harvard Medical School and
Harvard Pilgrim Health Care Institute
Boston, Massachusetts, U.S.A.

i i

i i
CRC Press
Taylor & Francis Group
6000 Broken Sound Parkway NW, Suite 300
Boca Raton, FL 33487-2742
© 2015 by Taylor & Francis Group, LLC
CRC Press is an imprint of Taylor & Francis Group, an Informa business

No claim to original U.S. Government works


Version Date: 20150126

International Standard Book Number-13: 978-1-4822-3737-5 (eBook - PDF)

This book contains information obtained from authentic and highly regarded sources. Reasonable efforts have been
made to publish reliable data and information, but the author and publisher cannot assume responsibility for the valid-
ity of all materials or the consequences of their use. The authors and publishers have attempted to trace the copyright
holders of all material reproduced in this publication and apologize to copyright holders if permission to publish in this
form has not been obtained. If any copyright material has not been acknowledged please write and let us know so we may
rectify in any future reprint.

Except as permitted under U.S. Copyright Law, no part of this book may be reprinted, reproduced, transmitted, or uti-
lized in any form by any electronic, mechanical, or other means, now known or hereafter invented, including photocopy-
ing, microfilming, and recording, or in any information storage or retrieval system, without written permission from the
publishers.

For permission to photocopy or use material electronically from this work, please access www.copyright.com (http://
www.copyright.com/) or contact the Copyright Clearance Center, Inc. (CCC), 222 Rosewood Drive, Danvers, MA 01923,
978-750-8400. CCC is a not-for-profit organization that provides licenses and registration for a variety of users. For
organizations that have been granted a photocopy license by the CCC, a separate system of payment has been arranged.

Trademark Notice: Product or corporate names may be trademarks or registered trademarks, and are used only for
identification and explanation without intent to infringe.
Visit the Taylor & Francis Web site at
http://www.taylorandfrancis.com
and the CRC Press Web site at
http://www.crcpress.com
i i

“K23166” — 2015/1/28 — 9:35 — page v — #7


i i

Contents

List of Tables xvii

List of Figures xix

Preface to the second edition xxi

Preface to the first edition xxiii

1 Data input and output 1


1.1 Input . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
1.1.1 Native dataset . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
1.1.2 Fixed format text files . . . . . . . . . . . . . . . . . . . . . . . . . . 1
1.1.3 Other fixed files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
1.1.4 Comma-separated value (CSV) files . . . . . . . . . . . . . . . . . . 2
1.1.5 Read sheets from an Excel file . . . . . . . . . . . . . . . . . . . . . 2
1.1.6 Read data from R into SAS . . . . . . . . . . . . . . . . . . . . . . . 2
1.1.7 Read data from SAS into R . . . . . . . . . . . . . . . . . . . . . . . 3
1.1.8 Reading datasets in other formats . . . . . . . . . . . . . . . . . . . 3
1.1.9 Reading more complex text files . . . . . . . . . . . . . . . . . . . . 3
1.1.10 Reading data with a variable number of words in a field . . . . . . . 4
1.1.11 Read a file byte by byte . . . . . . . . . . . . . . . . . . . . . . . . . 5
1.1.12 Access data from a URL . . . . . . . . . . . . . . . . . . . . . . . . . 5
1.1.13 Read an XML-formatted file . . . . . . . . . . . . . . . . . . . . . . 6
1.1.14 Read an HTML table . . . . . . . . . . . . . . . . . . . . . . . . . . 6
1.1.15 Manual data entry . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
1.2 Output . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
1.2.1 Displaying data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
1.2.2 Number of digits to display . . . . . . . . . . . . . . . . . . . . . . . 7
1.2.3 Save a native dataset . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
1.2.4 Creating datasets in text format . . . . . . . . . . . . . . . . . . . . 8
1.2.5 Creating Excel spreadsheets . . . . . . . . . . . . . . . . . . . . . . . 8
1.2.6 Creating files for use by other packages . . . . . . . . . . . . . . . . 8
1.2.7 Creating HTML formatted output . . . . . . . . . . . . . . . . . . . 8
1.2.8 Creating XML datasets and output . . . . . . . . . . . . . . . . . . . 9
1.3 Further resources . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9

v
i i

i i
i i

“K23166” — 2015/1/28 — 9:35 — page vi — #8


i i

vi CONTENTS

2 Data management 11
2.1 Structure and metadata . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
2.1.1 Access variables from a dataset . . . . . . . . . . . . . . . . . . . . . 11
2.1.2 Names of variables and their types . . . . . . . . . . . . . . . . . . . 11
2.1.3 Values of variables in a dataset . . . . . . . . . . . . . . . . . . . . . 12
2.1.4 Label variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
2.1.5 Add comment to a dataset or variable . . . . . . . . . . . . . . . . . 12
2.2 Derived variables and data manipulation . . . . . . . . . . . . . . . . . . . . 12
2.2.1 Add derived variable to a dataset . . . . . . . . . . . . . . . . . . . . 13
2.2.2 Rename variables in a dataset . . . . . . . . . . . . . . . . . . . . . . 13
2.2.3 Create string variables from numeric variables . . . . . . . . . . . . . 13
2.2.4 Create categorical variables from continuous variables . . . . . . . . 13
2.2.5 Recode a categorical variable . . . . . . . . . . . . . . . . . . . . . . 14
2.2.6 Create a categorical variable using logic . . . . . . . . . . . . . . . . 14
2.2.7 Create numeric variables from string variables . . . . . . . . . . . . . 15
2.2.8 Extract characters from string variables . . . . . . . . . . . . . . . . 15
2.2.9 Length of string variables . . . . . . . . . . . . . . . . . . . . . . . . 15
2.2.10 Concatenate string variables . . . . . . . . . . . . . . . . . . . . . . . 15
2.2.11 Set operations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
2.2.12 Find strings within string variables . . . . . . . . . . . . . . . . . . . 16
2.2.13 Find approximate strings . . . . . . . . . . . . . . . . . . . . . . . . 16
2.2.14 Replace strings within string variables . . . . . . . . . . . . . . . . . 17
2.2.15 Split strings into multiple strings . . . . . . . . . . . . . . . . . . . . 17
2.2.16 Remove spaces around string variables . . . . . . . . . . . . . . . . . 17
2.2.17 Convert strings from upper to lower case . . . . . . . . . . . . . . . 17
2.2.18 Create lagged variable . . . . . . . . . . . . . . . . . . . . . . . . . . 17
2.2.19 Formatting values of variables . . . . . . . . . . . . . . . . . . . . . . 18
2.2.20 Perl interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
2.2.21 Accessing databases using SQL . . . . . . . . . . . . . . . . . . . . . 18
2.3 Merging, combining, and subsetting datasets . . . . . . . . . . . . . . . . . 19
2.3.1 Subsetting observations . . . . . . . . . . . . . . . . . . . . . . . . . 19
2.3.2 Drop or keep variables in a dataset . . . . . . . . . . . . . . . . . . . 19
2.3.3 Random sample of a dataset . . . . . . . . . . . . . . . . . . . . . . 20
2.3.4 Observation number . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
2.3.5 Keep unique values . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
2.3.6 Identify duplicated values . . . . . . . . . . . . . . . . . . . . . . . . 20
2.3.7 Convert from wide to long (tall) format . . . . . . . . . . . . . . . . 21
2.3.8 Convert from long (tall) to wide format . . . . . . . . . . . . . . . . 21
2.3.9 Concatenate and stack datasets . . . . . . . . . . . . . . . . . . . . . 22
2.3.10 Sort datasets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
2.3.11 Merge datasets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
2.4 Date and time variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
2.4.1 Create date variable . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
2.4.2 Extract weekday . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
2.4.3 Extract month . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
2.4.4 Extract year . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
2.4.5 Extract quarter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
2.4.6 Create time variable . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
2.5 Further resources . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
2.6 Examples . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
2.6.1 Data input and output . . . . . . . . . . . . . . . . . . . . . . . . . . 25

i i

i i
i i

“K23166” — 2015/1/28 — 9:35 — page vii — #9


i i

CONTENTS vii

2.6.2 Data display . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27


2.6.3 Derived variables and data manipulation . . . . . . . . . . . . . . . . 27
2.6.4 Sorting and subsetting datasets . . . . . . . . . . . . . . . . . . . . . 31

3 Statistical and mathematical functions 33


3.1 Probability distributions and random number generation . . . . . . . . . . . 33
3.1.1 Probability density function . . . . . . . . . . . . . . . . . . . . . . . 33
3.1.2 Quantiles of a probability density function . . . . . . . . . . . . . . . 33
3.1.3 Setting the random number seed . . . . . . . . . . . . . . . . . . . . 34
3.1.4 Uniform random variables . . . . . . . . . . . . . . . . . . . . . . . . 34
3.1.5 Multinomial random variables . . . . . . . . . . . . . . . . . . . . . . 35
3.1.6 Normal random variables . . . . . . . . . . . . . . . . . . . . . . . . 35
3.1.7 Multivariate normal random variables . . . . . . . . . . . . . . . . . 35
3.1.8 Truncated multivariate normal random variables . . . . . . . . . . . 36
3.1.9 Exponential random variables . . . . . . . . . . . . . . . . . . . . . . 36
3.1.10 Other random variables . . . . . . . . . . . . . . . . . . . . . . . . . 36
3.2 Mathematical functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36
3.2.1 Basic functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36
3.2.2 Trigonometric functions . . . . . . . . . . . . . . . . . . . . . . . . . 37
3.2.3 Special functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37
3.2.4 Integer functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37
3.2.5 Comparisons of floating-point variables . . . . . . . . . . . . . . . . 38
3.2.6 Complex numbers . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38
3.2.7 Derivatives . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38
3.2.8 Integration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38
3.2.9 Optimization problems . . . . . . . . . . . . . . . . . . . . . . . . . . 39
3.3 Matrix operations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39
3.3.1 Create matrix from vector . . . . . . . . . . . . . . . . . . . . . . . . 39
3.3.2 Combine vectors or matrices . . . . . . . . . . . . . . . . . . . . . . 39
3.3.3 Matrix addition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39
3.3.4 Transpose matrix . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40
3.3.5 Find the dimension of a matrix or dataset . . . . . . . . . . . . . . . 40
3.3.6 Matrix multiplication . . . . . . . . . . . . . . . . . . . . . . . . . . 40
3.3.7 Finding the inverse of a matrix . . . . . . . . . . . . . . . . . . . . . 40
3.3.8 Component-wise multiplication . . . . . . . . . . . . . . . . . . . . . 40
3.3.9 Create a submatrix . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40
3.3.10 Create a diagonal matrix . . . . . . . . . . . . . . . . . . . . . . . . 40
3.3.11 Create a vector of diagonal elements . . . . . . . . . . . . . . . . . . 41
3.3.12 Create a vector from a matrix . . . . . . . . . . . . . . . . . . . . . . 41
3.3.13 Calculate the determinant . . . . . . . . . . . . . . . . . . . . . . . . 41
3.3.14 Find eigenvalues and eigenvectors . . . . . . . . . . . . . . . . . . . . 41
3.3.15 Find the singular value decomposition . . . . . . . . . . . . . . . . . 41
3.4 Examples . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42
3.4.1 Probability distributions . . . . . . . . . . . . . . . . . . . . . . . . . 42

4 Programming and operating system interface 45


4.1 Control flow, programming, and data generation . . . . . . . . . . . . . . . 45
4.1.1 Looping . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45
4.1.2 Conditional execution . . . . . . . . . . . . . . . . . . . . . . . . . . 45
4.1.3 Sequence of values or patterns . . . . . . . . . . . . . . . . . . . . . 46
4.1.4 Perform an action repeatedly over a set of variables . . . . . . . . . 46

i i

i i
i i

“K23166” — 2015/1/28 — 9:35 — page viii — #10


i i

viii CONTENTS

4.1.5 Grid of values . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47


4.1.6 Debugging . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47
4.1.7 Error recovery . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47
4.2 Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48
4.3 Interactions with the operating system . . . . . . . . . . . . . . . . . . . . . 49
4.3.1 Timing commands . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49
4.3.2 Suspend execution for a time interval . . . . . . . . . . . . . . . . . 49
4.3.3 Execute a command in the operating system . . . . . . . . . . . . . 49
4.3.4 Command history . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49
4.3.5 Find working directory . . . . . . . . . . . . . . . . . . . . . . . . . . 49
4.3.6 Change working directory . . . . . . . . . . . . . . . . . . . . . . . . 50
4.3.7 List and access files . . . . . . . . . . . . . . . . . . . . . . . . . . . 50
4.3.8 Create temporary file . . . . . . . . . . . . . . . . . . . . . . . . . . 50
4.3.9 Redirect output . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50

5 Common statistical procedures 51


5.1 Summary statistics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51
5.1.1 Means and other summary statistics . . . . . . . . . . . . . . . . . . 51
5.1.2 Weighted means and other statistics . . . . . . . . . . . . . . . . . . 51
5.1.3 Other moments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52
5.1.4 Trimmed mean . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52
5.1.5 Quantiles . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52
5.1.6 Centering, normalizing, and scaling . . . . . . . . . . . . . . . . . . . 52
5.1.7 Mean and 95% confidence interval . . . . . . . . . . . . . . . . . . . 52
5.1.8 Proportion and 95% confidence interval . . . . . . . . . . . . . . . . 53
5.1.9 Maximum likelihood estimation of parameters . . . . . . . . . . . . . 53
5.2 Bivariate statistics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53
5.2.1 Epidemiologic statistics . . . . . . . . . . . . . . . . . . . . . . . . . 53
5.2.2 Test characteristics . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54
5.2.3 Correlation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54
5.2.4 Kappa (agreement) . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54
5.3 Contingency tables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55
5.3.1 Display cross-classification table . . . . . . . . . . . . . . . . . . . . 55
5.3.2 Displaying missing value categories in a table . . . . . . . . . . . . . 55
5.3.3 Pearson chi-square statistic . . . . . . . . . . . . . . . . . . . . . . . 55
5.3.4 Cochran–Mantel–Haenszel test . . . . . . . . . . . . . . . . . . . . . 55
5.3.5 Cramér’s V . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56
5.3.6 Fisher’s exact test . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56
5.3.7 McNemar’s test . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56
5.4 Tests for continuous variables . . . . . . . . . . . . . . . . . . . . . . . . . . 56
5.4.1 Tests for normality . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56
5.4.2 Student’s t-test . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56
5.4.3 Test for equal variances . . . . . . . . . . . . . . . . . . . . . . . . . 57
5.4.4 Nonparametric tests . . . . . . . . . . . . . . . . . . . . . . . . . . . 57
5.4.5 Permutation test . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57
5.4.6 Logrank test . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 58
5.5 Analytic power and sample size calculations . . . . . . . . . . . . . . . . . . 58
5.6 Further resources . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59
5.7 Examples . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59
5.7.1 Summary statistics and exploratory data analysis . . . . . . . . . . . 59
5.7.2 Bivariate relationships . . . . . . . . . . . . . . . . . . . . . . . . . . 60

i i

i i
i i

“K23166” — 2015/1/28 — 9:35 — page ix — #11


i i

CONTENTS ix

5.7.3 Contingency tables . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61


5.7.4 Two sample tests of continuous variables . . . . . . . . . . . . . . . 64
5.7.5 Survival analysis: logrank test . . . . . . . . . . . . . . . . . . . . . 65

6 Linear regression and ANOVA 67


6.1 Model fitting . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67
6.1.1 Linear regression . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67
6.1.2 Linear regression with categorical covariates . . . . . . . . . . . . . . 68
6.1.3 Changing the reference category . . . . . . . . . . . . . . . . . . . . 68
6.1.4 Parameterization of categorical covariates . . . . . . . . . . . . . . . 68
6.1.5 Linear regression with no intercept . . . . . . . . . . . . . . . . . . . 69
6.1.6 Linear regression with interactions . . . . . . . . . . . . . . . . . . . 69
6.1.7 Linear regression with big data . . . . . . . . . . . . . . . . . . . . . 69
6.1.8 One-way analysis of variance . . . . . . . . . . . . . . . . . . . . . . 70
6.1.9 Analysis of variance with two or more factors . . . . . . . . . . . . . 70
6.2 Tests, contrasts, and linear functions of parameters . . . . . . . . . . . . . . 70
6.2.1 Joint null hypotheses: several parameters equal 0 . . . . . . . . . . . 70
6.2.2 Joint null hypotheses: sum of parameters . . . . . . . . . . . . . . . 70
6.2.3 Tests of equality of parameters . . . . . . . . . . . . . . . . . . . . . 70
6.2.4 Multiple comparisons . . . . . . . . . . . . . . . . . . . . . . . . . . 71
6.2.5 Linear combinations of parameters . . . . . . . . . . . . . . . . . . . 71
6.3 Model results and diagnostics . . . . . . . . . . . . . . . . . . . . . . . . . . 71
6.3.1 Predicted values . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 72
6.3.2 Residuals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 72
6.3.3 Standardized and Studentized residuals . . . . . . . . . . . . . . . . 72
6.3.4 Leverage . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 72
6.3.5 Cook’s distance . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 72
6.3.6 DFFITs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73
6.3.7 Diagnostic plots . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73
6.3.8 Heteroscedasticity tests . . . . . . . . . . . . . . . . . . . . . . . . . 73
6.4 Model parameters and results . . . . . . . . . . . . . . . . . . . . . . . . . . 73
6.4.1 Parameter estimates . . . . . . . . . . . . . . . . . . . . . . . . . . . 73
6.4.2 Standardized regression coefficients . . . . . . . . . . . . . . . . . . . 73
6.4.3 Coefficient plot . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 74
6.4.4 Standard errors of parameter estimates . . . . . . . . . . . . . . . . 74
6.4.5 Confidence interval for parameter estimates . . . . . . . . . . . . . . 74
6.4.6 Confidence limits for the mean . . . . . . . . . . . . . . . . . . . . . 74
6.4.7 Prediction limits . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 75
6.4.8 R-squared . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 75
6.4.9 Design and information matrix . . . . . . . . . . . . . . . . . . . . . 75
6.4.10 Covariance matrix of parameter estimates . . . . . . . . . . . . . . . 75
6.4.11 Correlation matrix of parameter estimates . . . . . . . . . . . . . . . 76
6.5 Further resources . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 76
6.6 Examples . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 76
6.6.1 Scatterplot with smooth fit . . . . . . . . . . . . . . . . . . . . . . . 76
6.6.2 Linear regression with interaction . . . . . . . . . . . . . . . . . . . . 77
6.6.3 Regression coefficient plot . . . . . . . . . . . . . . . . . . . . . . . . 81
6.6.4 Regression diagnostics . . . . . . . . . . . . . . . . . . . . . . . . . . 81
6.6.5 Fitting a regression model separately for each value of another variable 83
6.6.6 Two-way ANOVA . . . . . . . . . . . . . . . . . . . . . . . . . . . . 84
6.6.7 Multiple comparisons . . . . . . . . . . . . . . . . . . . . . . . . . . 87

i i

i i
i i

“K23166” — 2015/1/28 — 9:35 — page x — #12


i i

x CONTENTS

6.6.8 Contrasts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 88

7 Regression generalizations and modeling 91


7.1 Generalized linear models . . . . . . . . . . . . . . . . . . . . . . . . . . . . 91
7.1.1 Logistic regression model . . . . . . . . . . . . . . . . . . . . . . . . 91
7.1.2 Conditional logistic regression model . . . . . . . . . . . . . . . . . . 91
7.1.3 Exact logistic regression . . . . . . . . . . . . . . . . . . . . . . . . . 92
7.1.4 Ordered logistic model . . . . . . . . . . . . . . . . . . . . . . . . . . 92
7.1.5 Generalized logistic model . . . . . . . . . . . . . . . . . . . . . . . . 93
7.1.6 Poisson model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 93
7.1.7 Negative binomial model . . . . . . . . . . . . . . . . . . . . . . . . 93
7.1.8 Log-linear model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 93
7.2 Further generalizations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 93
7.2.1 Zero-inflated Poisson model . . . . . . . . . . . . . . . . . . . . . . . 93
7.2.2 Zero-inflated negative binomial model . . . . . . . . . . . . . . . . . 94
7.2.3 Generalized additive model . . . . . . . . . . . . . . . . . . . . . . . 94
7.2.4 Nonlinear least squares model . . . . . . . . . . . . . . . . . . . . . . 94
7.3 Robust methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 95
7.3.1 Quantile regression model . . . . . . . . . . . . . . . . . . . . . . . . 95
7.3.2 Robust regression model . . . . . . . . . . . . . . . . . . . . . . . . . 95
7.3.3 Ridge regression model . . . . . . . . . . . . . . . . . . . . . . . . . 95
7.4 Models for correlated data . . . . . . . . . . . . . . . . . . . . . . . . . . . . 95
7.4.1 Linear models with correlated outcomes . . . . . . . . . . . . . . . . 96
7.4.2 Linear mixed models with random intercepts . . . . . . . . . . . . . 96
7.4.3 Linear mixed models with random slopes . . . . . . . . . . . . . . . 96
7.4.4 More complex random coefficient models . . . . . . . . . . . . . . . . 97
7.4.5 Multilevel models . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 97
7.4.6 Generalized linear mixed models . . . . . . . . . . . . . . . . . . . . 97
7.4.7 Generalized estimating equations . . . . . . . . . . . . . . . . . . . . 97
7.4.8 MANOVA . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 98
7.4.9 Time series model . . . . . . . . . . . . . . . . . . . . . . . . . . . . 98
7.5 Survival analysis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 98
7.5.1 Proportional hazards (Cox) regression model . . . . . . . . . . . . . 98
7.5.2 Proportional hazards (Cox) model with frailty . . . . . . . . . . . . 99
7.5.3 Nelson–Aalen estimate of cumulative hazard . . . . . . . . . . . . . 99
7.5.4 Testing the proportionality of the Cox model . . . . . . . . . . . . . 99
7.5.5 Cox model with time-varying predictors . . . . . . . . . . . . . . . . 100
7.6 Multivariate statistics and discriminant procedures . . . . . . . . . . . . . . 100
7.6.1 Cronbach’s α . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 100
7.6.2 Factor analysis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 100
7.6.3 Recursive partitioning . . . . . . . . . . . . . . . . . . . . . . . . . . 100
7.6.4 Linear discriminant analysis . . . . . . . . . . . . . . . . . . . . . . . 100
7.6.5 Latent class analysis . . . . . . . . . . . . . . . . . . . . . . . . . . . 101
7.6.6 Hierarchical clustering . . . . . . . . . . . . . . . . . . . . . . . . . . 101
7.7 Complex survey design . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 101
7.8 Model selection and assessment . . . . . . . . . . . . . . . . . . . . . . . . . 102
7.8.1 Compare two models . . . . . . . . . . . . . . . . . . . . . . . . . . . 102
7.8.2 Log-likelihood . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 102
7.8.3 Akaike Information Criterion (AIC) . . . . . . . . . . . . . . . . . . 102
7.8.4 Bayesian Information Criterion (BIC) . . . . . . . . . . . . . . . . . 102
7.8.5 LASSO model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 102

i i

i i
i i

“K23166” — 2015/1/28 — 9:35 — page xi — #13


i i

CONTENTS xi

7.8.6 Hosmer–Lemeshow goodness of fit . . . . . . . . . . . . . . . . . . . 103


7.8.7 Goodness of fit for count models . . . . . . . . . . . . . . . . . . . . 103
7.9 Further resources . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 103
7.10 Examples . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 104
7.10.1 Logistic regression . . . . . . . . . . . . . . . . . . . . . . . . . . . . 104
7.10.2 Poisson regression . . . . . . . . . . . . . . . . . . . . . . . . . . . . 105
7.10.3 Zero-inflated Poisson regression . . . . . . . . . . . . . . . . . . . . . 106
7.10.4 Negative binomial regression . . . . . . . . . . . . . . . . . . . . . . 107
7.10.5 Quantile regression . . . . . . . . . . . . . . . . . . . . . . . . . . . . 107
7.10.6 Ordered logistic . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 108
7.10.7 Generalized logistic model . . . . . . . . . . . . . . . . . . . . . . . . 108
7.10.8 Generalized additive model . . . . . . . . . . . . . . . . . . . . . . . 109
7.10.9 Reshaping a dataset for longitudinal regression . . . . . . . . . . . . 110
7.10.10 Linear model for correlated data . . . . . . . . . . . . . . . . . . . . 112
7.10.11 Linear mixed (random slope) model . . . . . . . . . . . . . . . . . . 113
7.10.12 Generalized estimating equations . . . . . . . . . . . . . . . . . . . . 115
7.10.13 Generalized linear mixed model . . . . . . . . . . . . . . . . . . . . . 116
7.10.14 Cox proportional hazards model . . . . . . . . . . . . . . . . . . . . 117
7.10.15 Cronbach’s α . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 117
7.10.16 Factor analysis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 118
7.10.17 Recursive partitioning . . . . . . . . . . . . . . . . . . . . . . . . . . 119
7.10.18 Linear discriminant analysis . . . . . . . . . . . . . . . . . . . . . . . 120
7.10.19 Hierarchical clustering . . . . . . . . . . . . . . . . . . . . . . . . . . 121

8 A graphical compendium 123


8.1 Univariate plots . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 123
8.1.1 Barplot . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 123
8.1.2 Stem-and-leaf plot . . . . . . . . . . . . . . . . . . . . . . . . . . . . 124
8.1.3 Dotplot . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 124
8.1.4 Histogram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 124
8.1.5 Density plot . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 124
8.1.6 Empirical cumulative probability density plot . . . . . . . . . . . . . 125
8.1.7 Boxplot . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 125
8.1.8 Violin plots . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 125
8.2 Univariate plots by grouping variable . . . . . . . . . . . . . . . . . . . . . . 125
8.2.1 Side-by-side histograms . . . . . . . . . . . . . . . . . . . . . . . . . 125
8.2.2 Side-by-side boxplots . . . . . . . . . . . . . . . . . . . . . . . . . . . 125
8.2.3 Overlaid density plots . . . . . . . . . . . . . . . . . . . . . . . . . . 126
8.2.4 Bar chart with error bars . . . . . . . . . . . . . . . . . . . . . . . . 126
8.3 Bivariate plots . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 127
8.3.1 Scatterplot . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 127
8.3.2 Scatterplot with multiple y values . . . . . . . . . . . . . . . . . . . 127
8.3.3 Scatterplot with binning . . . . . . . . . . . . . . . . . . . . . . . . . 128
8.3.4 Transparent overplotting scatterplot . . . . . . . . . . . . . . . . . . 128
8.3.5 Bivariate density plot . . . . . . . . . . . . . . . . . . . . . . . . . . 128
8.3.6 Scatterplot with marginal histograms . . . . . . . . . . . . . . . . . 129
8.4 Multivariate plots . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 129
8.4.1 Matrix of scatterplots . . . . . . . . . . . . . . . . . . . . . . . . . . 129
8.4.2 Conditioning plot . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 129
8.4.3 Contour plots . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 130
8.4.4 3-D plots . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 130

i i

i i
i i

“K23166” — 2015/1/28 — 9:35 — page xii — #14


i i

xii CONTENTS

8.5 Special-purpose plots . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 130


8.5.1 Choropleth maps . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 130
8.5.2 Interaction plots . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 130
8.5.3 Plots for categorical data . . . . . . . . . . . . . . . . . . . . . . . . 131
8.5.4 Circular plot . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 131
8.5.5 Plot an arbitrary function . . . . . . . . . . . . . . . . . . . . . . . . 131
8.5.6 Normal quantile–quantile plot . . . . . . . . . . . . . . . . . . . . . . 131
8.5.7 Receiver operating characteristic (ROC) curve . . . . . . . . . . . . 132
8.5.8 Plot confidence intervals for the mean . . . . . . . . . . . . . . . . . 132
8.5.9 Plot prediction limits from a simple linear regression . . . . . . . . . 132
8.5.10 Plot predicted lines for each value of a variable . . . . . . . . . . . . 132
8.5.11 Kaplan–Meier plot . . . . . . . . . . . . . . . . . . . . . . . . . . . . 133
8.5.12 Hazard function plotting . . . . . . . . . . . . . . . . . . . . . . . . . 133
8.5.13 Mean–difference plots . . . . . . . . . . . . . . . . . . . . . . . . . . 133
8.6 Further resources . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 134
8.7 Examples . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 134
8.7.1 Scatterplot with multiple axes . . . . . . . . . . . . . . . . . . . . . 134
8.7.2 Conditioning plot . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 135
8.7.3 Scatterplot with marginal histograms . . . . . . . . . . . . . . . . . 135
8.7.4 Kaplan–Meier plot . . . . . . . . . . . . . . . . . . . . . . . . . . . . 137
8.7.5 ROC curve . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 138
8.7.6 Pairs plot . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 138
8.7.7 Visualize correlation matrix . . . . . . . . . . . . . . . . . . . . . . . 141

9 Graphical options and configuration 145


9.1 Adding elements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 145
9.1.1 Arbitrary straight line . . . . . . . . . . . . . . . . . . . . . . . . . . 145
9.1.2 Plot symbols . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 145
9.1.3 Add points to an existing graphic . . . . . . . . . . . . . . . . . . . . 146
9.1.4 Jitter points . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 146
9.1.5 Regression line fit to points . . . . . . . . . . . . . . . . . . . . . . . 146
9.1.6 Smoothed line . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 146
9.1.7 Normal density . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 147
9.1.8 Marginal rug plot . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 147
9.1.9 Titles . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 147
9.1.10 Footnotes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 147
9.1.11 Text . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 147
9.1.12 Mathematical symbols . . . . . . . . . . . . . . . . . . . . . . . . . . 148
9.1.13 Arrows and shapes . . . . . . . . . . . . . . . . . . . . . . . . . . . . 148
9.1.14 Add grid . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 148
9.1.15 Legend . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 148
9.1.16 Identifying and locating points . . . . . . . . . . . . . . . . . . . . . 148
9.2 Options and parameters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 149
9.2.1 Graph size . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 149
9.2.2 Grid of plots per page . . . . . . . . . . . . . . . . . . . . . . . . . . 149
9.2.3 More general page layouts . . . . . . . . . . . . . . . . . . . . . . . . 149
9.2.4 Fonts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 150
9.2.5 Point and text size . . . . . . . . . . . . . . . . . . . . . . . . . . . . 150
9.2.6 Box around plots . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 150
9.2.7 Size of margins . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 150
9.2.8 Graphical settings . . . . . . . . . . . . . . . . . . . . . . . . . . . . 150

i i

i i
i i

“K23166” — 2015/1/28 — 9:35 — page xiii — #15


i i

CONTENTS xiii

9.2.9 Axis range and style . . . . . . . . . . . . . . . . . . . . . . . . . . . 151


9.2.10 Axis labels, values, and tick marks . . . . . . . . . . . . . . . . . . . 151
9.2.11 Line styles . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 151
9.2.12 Line widths . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 151
9.2.13 Colors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 151
9.2.14 Log scale . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 152
9.2.15 Omit axes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 152
9.3 Saving graphs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 152
9.3.1 PDF . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 152
9.3.2 Postscript . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 152
9.3.3 RTF . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 152
9.3.4 JPEG . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 153
9.3.5 Windows Metafile . . . . . . . . . . . . . . . . . . . . . . . . . . . . 153
9.3.6 Bitmap image file (BMP) . . . . . . . . . . . . . . . . . . . . . . . . 153
9.3.7 Tagged Image File Format . . . . . . . . . . . . . . . . . . . . . . . . 153
9.3.8 PNG . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 153
9.3.9 Closing a graphic device . . . . . . . . . . . . . . . . . . . . . . . . . 153

10 Simulation 155
10.1 Generating data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 155
10.1.1 Generate categorical data . . . . . . . . . . . . . . . . . . . . . . . . 155
10.1.2 Generate data from a logistic regression . . . . . . . . . . . . . . . . 156
10.1.3 Generate data from a generalized linear mixed model . . . . . . . . . 156
10.1.4 Generate correlated binary data . . . . . . . . . . . . . . . . . . . . 157
10.1.5 Generate data from a Cox model . . . . . . . . . . . . . . . . . . . . 158
10.1.6 Sampling from a challenging distribution . . . . . . . . . . . . . . . 159
10.2 Simulation applications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 161
10.2.1 Simulation study of Student’s t-test . . . . . . . . . . . . . . . . . . 161
10.2.2 Diploma (or hat-check) problem . . . . . . . . . . . . . . . . . . . . 162
10.2.3 Monty Hall problem . . . . . . . . . . . . . . . . . . . . . . . . . . . 163
10.2.4 Censored survival . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 165
10.3 Further resources . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 165

11 Special topics 167


11.1 Processing by group . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 167
11.1.1 Means by group . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 167
11.1.2 Linear models stratified by each value of a grouping variable . . . . 168
11.2 Simulation-based power calculations . . . . . . . . . . . . . . . . . . . . . . 169
11.3 Reproducible analysis and output . . . . . . . . . . . . . . . . . . . . . . . . 171
11.4 Advanced statistical methods . . . . . . . . . . . . . . . . . . . . . . . . . . 173
11.4.1 Bayesian methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . 173
11.4.2 Propensity scores . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 177
11.4.3 Bootstrapping . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 181
11.4.4 Missing data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 182
11.4.5 Finite mixture models with concomitant variables . . . . . . . . . . 185
11.5 Further resources . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 186

i i

i i
i i

“K23166” — 2015/1/28 — 9:35 — page xiv — #16


i i

xiv CONTENTS

12 Case studies 187


12.1 Data management and related tasks . . . . . . . . . . . . . . . . . . . . . . 187
12.1.1 Finding two closest values in a vector . . . . . . . . . . . . . . . . . 187
12.1.2 Tabulate binomial probabilities . . . . . . . . . . . . . . . . . . . . . 188
12.1.3 Calculate and plot a running average . . . . . . . . . . . . . . . . . . 188
12.1.4 Create a Fibonacci sequence . . . . . . . . . . . . . . . . . . . . . . . 189
12.2 Read variable format files . . . . . . . . . . . . . . . . . . . . . . . . . . . . 190
12.3 Plotting maps . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 192
12.3.1 Massachusetts counties, continued . . . . . . . . . . . . . . . . . . . 192
12.3.2 Bike ride plot . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 193
12.3.3 Choropleth maps . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 193
12.4 Data scraping . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 195
12.4.1 Scraping data from HTML files . . . . . . . . . . . . . . . . . . . . . 195
12.4.2 Reading data with two lines per observation . . . . . . . . . . . . . . 196
12.4.3 Plotting time series data . . . . . . . . . . . . . . . . . . . . . . . . . 197
12.4.4 Reading tables from HTML . . . . . . . . . . . . . . . . . . . . . . . 198
12.4.5 URL APIs and truly random numbers . . . . . . . . . . . . . . . . . 199
12.4.6 Reading from a web API . . . . . . . . . . . . . . . . . . . . . . . . 200
12.5 Text mining . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 202
12.5.1 Retrieving data from arXiv.org . . . . . . . . . . . . . . . . . . . . . 202
12.5.2 Exploratory text mining . . . . . . . . . . . . . . . . . . . . . . . . . 202
12.6 Interactive visualization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 203
12.6.1 Visualization using the grammar of graphics (ggvis) . . . . . . . . . 203
12.6.2 Shiny in Markdown . . . . . . . . . . . . . . . . . . . . . . . . . . . 205
12.6.3 Creating a standalone Shiny app . . . . . . . . . . . . . . . . . . . . 206
12.7 Manipulating bigger datasets . . . . . . . . . . . . . . . . . . . . . . . . . . 207
12.8 Constrained optimization: the knapsack problem . . . . . . . . . . . . . . . 208

A Introduction to R and RStudio 211


A.1 Installation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 212
A.1.1 Installation under Windows . . . . . . . . . . . . . . . . . . . . . . . 212
A.1.2 Installation under Mac OS X . . . . . . . . . . . . . . . . . . . . . . 213
A.1.3 RStudio . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 213
A.1.4 Other graphical interfaces . . . . . . . . . . . . . . . . . . . . . . . . 213
A.2 Running R and sample session . . . . . . . . . . . . . . . . . . . . . . . . . 214
A.2.1 Replicating examples from the book and sourcing commands . . . . 215
A.2.2 Batch mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 216
A.3 Learning R . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 216
A.3.1 Getting help . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 216
A.3.2 swirl . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 217
A.4 Fundamental structures and objects . . . . . . . . . . . . . . . . . . . . . . 220
A.4.1 Objects and vectors . . . . . . . . . . . . . . . . . . . . . . . . . . . 221
A.4.2 Indexing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 221
A.4.3 Operators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 222
A.4.4 Lists . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 222
A.4.5 Matrices . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 223
A.4.6 Dataframes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 223
A.4.7 Attributes and classes . . . . . . . . . . . . . . . . . . . . . . . . . . 226
A.4.8 Options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 226
A.5 Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 226
A.5.1 Calling functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 226

i i

i i
i i

“K23166” — 2015/1/28 — 9:35 — page xv — #17


i i

CONTENTS xv

A.5.2 The apply family of functions . . . . . . . . . . . . . . . . . . . . . . 227


A.5.3 Pipes and connections between functions . . . . . . . . . . . . . . . 228
A.6 Add-ons: packages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 229
A.6.1 Introduction to packages . . . . . . . . . . . . . . . . . . . . . . . . . 229
A.6.2 Packages and name conflicts . . . . . . . . . . . . . . . . . . . . . . . 230
A.6.3 Maintaining packages . . . . . . . . . . . . . . . . . . . . . . . . . . 231
A.6.4 CRAN task views . . . . . . . . . . . . . . . . . . . . . . . . . . . . 231
A.6.5 Installed libraries and packages . . . . . . . . . . . . . . . . . . . . . 231
A.6.6 Packages referenced in this book . . . . . . . . . . . . . . . . . . . . 233
A.6.7 Datasets available with R . . . . . . . . . . . . . . . . . . . . . . . . 236
A.7 Support and bugs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 236

B The HELP study dataset 237


B.1 Background on the HELP study . . . . . . . . . . . . . . . . . . . . . . . . 237
B.2 Roadmap to analyses of the HELP dataset . . . . . . . . . . . . . . . . . . 237
B.3 Detailed description of the dataset . . . . . . . . . . . . . . . . . . . . . . . 239

C References 243

D Indices 255
D.1 Subject index . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 255
D.2 R index . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 276

i i

i i
i i

“K23166” — 2015/1/28 — 9:35 — page xvi — #18


i i

i i

i i
i i

“K23166” — 2015/1/28 — 9:35 — page xvii — #19


i i

List of Tables

3.1 Quantiles, probabilities, and pseudo-random number generation: available


distributions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34

6.1 Formatted results using the xtable package . . . . . . . . . . . . . . . . . . 80

7.1 Generalized linear model distributions supported . . . . . . . . . . . . . . . 92

11.1 Bayesian modeling functions available within the MCMCpack package . . . . 175

12.1 Weights, volume, and values for the knapsack problem . . . . . . . . . . . . 209

A.1 Interactive courses available within swirl . . . . . . . . . . . . . . . . . . . . 219


A.2 CRAN task views . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 232

B.1 Analyses undertaken using the HELP dataset . . . . . . . . . . . . . . . . . 237


B.2 Annotated description of variables in the HELP dataset . . . . . . . . . . . 239

xvii
i i

i i
i i

“K23166” — 2015/1/28 — 9:35 — page xviii — #20


i i

i i

i i
i i

“K23166” — 2015/1/28 — 9:35 — page xix — #21


i i

List of Figures

3.1 Comparison of standard normal and t distribution with 1 df . . . . . . . . . 42


3.2 Descriptive plot of the normal distribution . . . . . . . . . . . . . . . . . . . 43

5.1 Density plot of depressive symptom scores (CESD) plus superimposed his-
togram and normal distribution . . . . . . . . . . . . . . . . . . . . . . . . . 60
5.2 Scatterplot of CESD and MCS for women, with primary substance shown as
the plot symbol . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61
5.3 Graphical display of the table of substance by race/ethnicity . . . . . . . . 63
5.4 Density plot of age by gender . . . . . . . . . . . . . . . . . . . . . . . . . . 65

6.1 Scatterplot of observed values for age and I1 (plus smoothers by substance)
using base graphics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 77
6.2 Scatterplot of observed values for age and I1 (plus smoothers by substance)
using the lattice package . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78
6.3 Scatterplot of observed values for age and I1 (plus smoothers by substance)
using the ggplot2 package . . . . . . . . . . . . . . . . . . . . . . . . . . . . 79
6.4 Regression coefficient plot . . . . . . . . . . . . . . . . . . . . . . . . . . . . 82
6.5 Default diagnostics for linear models . . . . . . . . . . . . . . . . . . . . . . 83
6.6 Empirical density of residuals, with superimposed normal density . . . . . . 84
6.7 Interaction plot of CESD as a function of substance group and gender . . . 85
6.8 Boxplot of CESD as a function of substance group and gender . . . . . . . 86
6.9 Pairwise comparisons (using Tukey HSD procedure) . . . . . . . . . . . . . 88
6.10 Pairwise comparisons (using the factorplot function) . . . . . . . . . . . . . 89

7.1 Scatterplots of smoothed association of physical component score (PCS) with


CESD . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 111
7.2 Side-by-side box plots of CESD by treatment and time . . . . . . . . . . . . 114
7.3 Recursive partitioning tree . . . . . . . . . . . . . . . . . . . . . . . . . . . . 120
7.4 Graphical display of assignment probabilities or score functions from linear
discriminant analysis by actual homeless status . . . . . . . . . . . . . . . . 122
7.5 Results from hierarchical clustering . . . . . . . . . . . . . . . . . . . . . . . 122

8.1 Plot of InDUC and MCS vs. CESD for female alcohol-involved subjects . . 135
8.2 Association of MCS and CESD, stratified by substance and report of suicidal
thoughts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 136
8.3 Lattice settings using the mosaic black-and-white theme . . . . . . . . . . . 137
8.4 Association of MCS and PCS with marginal histograms . . . . . . . . . . . 138
8.5 Kaplan–Meier estimate of time to linkage to primary care by randomization
group . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 139

xix
i i

i i
i i

“K23166” — 2015/1/28 — 9:35 — page xx — #22


i i

xx LIST OF FIGURES

8.6 Receiver operating characteristic curve for the logistical regression model pre-
dicting suicidal thoughts using the CESD as a measure of depressive symp-
toms (sensitivity = true positive rate; 1-specificity = false positive rate) . . 140
8.7 Pairs plot of variables from the HELP dataset using the lattice package . 141
8.8 Pairs plot of variables from the HELP dataset using the GGally package. . 142
8.9 Visual display of correlations (times 100) . . . . . . . . . . . . . . . . . . . . 143

10.1 Plot of true and simulated distributions . . . . . . . . . . . . . . . . . . . . 161

11.1 Generating a new R Markdown file in RStudio . . . . . . . . . . . . . . . . 172


11.2 Sample Markdown input file . . . . . . . . . . . . . . . . . . . . . . . . . . . 173
11.3 Formatted output from R Markdown example . . . . . . . . . . . . . . . . . 174

12.1 Running average for Cauchy and t distributions . . . . . . . . . . . . . . . . 190


12.2 Massachusetts counties . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 192
12.3 Bike ride plot . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 194
12.4 Choropleth map . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 195
12.5 Sales plot by time . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 198
12.6 List of questions tagged with dplyr on the Stackexchange website . . . . . 201
12.7 Interactive graphical display . . . . . . . . . . . . . . . . . . . . . . . . . . . 204
12.8 Shiny within R Markdown . . . . . . . . . . . . . . . . . . . . . . . . . . . . 205
12.9 Display of Shiny document within Markdown . . . . . . . . . . . . . . . . . 206
12.10Number of flights departing Bradley airport on Mondays over time . . . . . 209

A.1 R Windows graphical user interface . . . . . . . . . . . . . . . . . . . . . . . 212


A.2 R Mac OS X graphical user interface . . . . . . . . . . . . . . . . . . . . . . 213
A.3 RStudio graphical user interface . . . . . . . . . . . . . . . . . . . . . . . . . 214
A.4 Sample session in R . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 215
A.5 Documentation on the mean() function . . . . . . . . . . . . . . . . . . . . 218
A.6 Display after running RSiteSearch("eta squared anova") . . . . . . . . . 219

i i

i i
i i

“K23166” — 2015/1/28 — 9:35 — page xxi — #23


i i

Preface to the second edition

Software systems such as R evolve rapidly, and so do the approaches and expertise of
statistical analysts.
In 2009, we began a blog in which we explored many new case studies and applications,
ranging from generating a Fibonacci series to fitting finite mixture models with concomitant
variables. We also discussed some additions to R, the RStudio integrated development
environment, and new or improved R packages. The blog now has hundreds of entries and
according to Google Analytics has received hundreds of thousands of visits.
The volume you are holding is a larger format and longer than the first edition, and
much of the new material is adapted from these blog entries, while it also includes other
improvements and additions that have emerged in the last few years.
We have extensively reorganized the material in the book and created three new chap-
ters. The firsts, “Simulation,” includes examples where data are generated from complex
models such as mixed-effects models and survival models, and from distributions using
the Metropolis–Hastings algorithm. We also explore interesting statistics and probability
examples via simulation. The second is “Special topics,” where we describe some key fea-
tures, such as processing by group, and detail several important areas of statistics, including
Bayesian methods, propensity scores, and bootstrapping. The last is “Case studies,” where
we demonstrate examples of useful data management tasks, read complex files, make and
annotate maps, show how to “scrape” data from the web, mine text files, and generate
dynamic graphics.
We also describe RStudio in detail. This powerful and easy-to-use front end adds in-
numerable features to R. In our experience, it dramatically increases the productivity of R
users, and by tightly integrating reproducible analysis tools, helps avoid error-prone “cut
and paste” workflows. Our students and colleagues find RStudio an extremely comfortable
interface.
We used a reproducible analysis system (knitr) to generate the example code and
output in the book. Code extracted from these files is provided on the book website. In
this edition, we provide a detailed discussion of the philosophy and use of these systems. In
particular, we feel that the knitr and markdown packages for R, which are tightly integrated
with RStudio, should become a part of every R user’s toolbox. We can’t imagine working
on a project without them.
The second edition of the book features extensive use of a number of new packages
that extend the functionality of the system. These include dplyr (tools for working with
dataframe-like objects and databases), ggplot2 (implementation of the Grammar of Graph-
ics), ggmap (spatial mapping using ggplot2), ggvis (to build interactive graphical displays),
httr (tools for working with URLs and HTTP), lubridate (date and time manipulations),
markdown (for simplified reproducible analysis), shiny (to build interactive web applica-
tions), swirl (for learning R, in R), tidyr (for data manipulation), and xtable (to cre-
ate publication-quality tables). Overall, these packages facilitate ever more sophisticated
analyses.

xxi
i i

i i
i i

“K23166” — 2015/1/28 — 9:35 — page xxii — #24


i i

xxii PREFACE TO THE SECOND EDITION

Finally, we’ve reorganized much of the material from the first edition into smaller, more
focused chapters. Readers will now find separate (and enhanced) chapters on data input
and output, data management, statistical and mathematical functions, and programming,
rather than a single chapter on “data management.” Graphics are now discussed in two
chapters: one on high-level types of plots, such as scatterplots and histograms, and another
on customizing the fine details of the plots, such as the number of tick marks and the color
of plot symbols.
We’re immensely gratified by the positive response the first edition elicited, and hope
the current volume will be even more useful to you.

On the web
The book website at http://www.amherst.edu/~nhorton/r2 includes the table of contents,
the indices, the HELP dataset in various formats, example code, a pointer to the blog, and
a list of errata.

Acknowledgments
In addition to those acknowledged in the first edition, we would like to thank J.J. Allaire
and the RStudio developers, Danny Kaplan, Deborah Nolan, Daniel Parel, Randall Pruim,
Romain Francois, and Hadley Wickham, plus the many individuals who have created and
shared R packages. Their contributions to R and RStudio, programming efforts, comments,
and guidance and/or helpful suggestions on drafts of the revision have been extremely
helpful. Above all, we greatly appreciate Sara and Julia as well as Abby, Alana, Kinari,
and Sam, for their patience and support.

Amherst, MA
October 2014

i i

i i
i i

“K23166” — 2015/1/28 — 9:35 — page xxiii — #25


i i

Preface to the first edition

R (R development core team, 2009) is a general purpose statistical software package used
in many fields of research. It is licensed for free, as open-source software. The system is
developed by a large group of people, almost all volunteers. It has a large and growing user
and developer base. Methodologists often release applications for general use in R shortly
after they have been introduced into the literature. While professional customer support is
not provided, there are many resources to help support users.
We have written this book as a reference text for users of R. Our primary goal is to
provide users with an easy way to learn how to perform an analytic task in this system,
without having to navigate through the extensive, idiosyncratic, and sometimes unwieldy
documentation or to sort through the huge number of add-on packages. We include many
common tasks, including data management, descriptive summaries, inferential procedures,
regression analysis, multivariate methods, and the creation of graphics. We also show some
more complex applications. In toto, we hope that the text will facilitate more efficient use
of this powerful system.
We do not attempt to exhaustively detail all possible ways available to accomplish a
given task in each system. Neither do we claim to provide the most elegant solution. We
have tried to provide a simple approach that is easy to understand for a new user, and have
supplied several solutions when it seems likely to be helpful.

Who should use this book

Those with an understanding of statistics at the level of multiple-regression analysis


should find this book helpful. This group includes professional analysts who use statistical
packages almost every day as well as statisticians, epidemiologists, economists, engineers,
physicians, sociologists, and others engaged in research or data analysis. We anticipate that
this tool will be particularly useful for sophisticated users, those with years of experience
in only one system, who need or want to use the other system. However, intermediate-
level analysts should reap the same benefit. In addition, the book will bolster the analytic
abilities of a relatively new user, by providing a concise reference manual and annotated
examples.

Using the book

The book has two indices, in addition to the comprehensive table of contents. These
include: 1) a detailed topic (subject) index in English; 2) an R command index, describing
R syntax.
Extensive example analyses of data from a clinical trial are presented; see Table B.1
(p. 237) for a comprehensive list. These employ a single dataset (from the HELP study),
described in Appendix B. Readers are encouraged to download the dataset and code from
the book website. The examples demonstrate the code in action and facilitate exploration
by the reader.

xxiii
i i

i i
i i

“K23166” — 2015/1/28 — 9:35 — page xxiv — #26


i i

xxiv PREFACE TO THE FIRST EDITION

In addition to the HELP examples, a case studies and extended examples chapter uti-
lizes many of the functions, idioms and code samples introduced earlier. These include
explications of analytic and empirical power calculations, missing data methods, propensity
score analysis, sophisticated data manipulation, data gleaning from websites, map making,
simulation studies, and optimization. Entries from earlier chapters are cross-referenced to
help guide the reader.
Where to begin
We do not anticipate that the book will be read cover to cover. Instead, we hope that the
extensive indexing, cross-referencing, and worked examples will make it possible for readers
to directly find and then implement what they need. A new user should begin by reading
the first chapter, which includes a sample session and overview of the system. Experienced
users may find the case studies to be valuable as a source of ideas on problem solving in R.
Acknowledgments
We would like to thank Rob Calver, Kari Budyk, Shashi Kumar, and Sarah Morris for
their support and guidance at Informa CRC/Chapman and Hall. We also thank Ben Cowl-
ing, Stephanie Greenlaw, Tanya Hakim, Albyn Jones, Michael Lavine, Pamela Matheson,
Elizabeth Stuart, Rebbecca Wilson, and Andrew Zieffler for comments, guidance and/or
helpful suggestions on drafts of the manuscript.
Above all we greatly appreciate Julia and Sara as well as Abby, Alana, Kinari, and Sam,
for their patience and support.

Northampton, MA and Amherst, MA


February, 2010

i i

i i
Another random document with
no related content on Scribd:
vengeance. Maintenant que te voici ramené à Dieu, as-tu
complètement dépouillé le vieil homme ?
Lorsque tu profères cette redoutable demande, es-tu bien assuré
de pardonner aux autres le mal qu’ils te firent ? En un mot, leur
remets-tu leur dette comme tu supplies notre Père de te remettre la
tienne ? Je dois te demander cela car songe quelle serait ta faute si,
lorsque tu invoques la miséricorde divine, tu gardais, au fond de ton
cœur, du mauvais vouloir à l’égard d’autrui !
Il y eut un silence. Chériat, les mains jointes, s’interrogeait lui-
même. Cependant Robert remarqua que Charles attendait la
réponse. Il s’était à demi-tourné vers le lit et, le sourcil froncé, il
observait Chériat comme pour juger de son état d’esprit.
— Je sais, dit enfin Chériat, que je serais indigne de la bonté de
Dieu si, quand je le supplie de me pardonner mes égarements, je
conservais de l’animosité contre ceux qui les partagèrent. Les
souffrances méritées que j’endure m’apprirent que la douleur est la
loi du monde. Les illusionnés qui croient s’en affranchir en festoyant
leur égoïsme au dépens de leur semblables, je les haïssais naguère.
Aujourd’hui, je les plains car je n’ignore pas que, tôt ou tard, dans
cette vie ou dans l’autre, ils pâtiront en proportion du mal qu’ils
auront commis ou approuvé.
Non, poursuivit-il, les yeux pleins de larmes et la voix tremblante,
je ne puis plus haïr personne. J’ai trop besoin de l’indulgence divine
pour ne pas concevoir que quiconque vit dans le péché en a besoin
autant que moi. N’est-ce pas, ami, que mon orgueil est bien mort
puisque Dieu me fait cette grande grâce de pouvoir dire avec
sincérité : Pardonnez-nous nos offenses comme nous pardonnons à
ceux qui nous ont offensés ? C’est pourquoi je lui témoignerai ma
reconnaissance en employant le peu de jours qui me restent non
seulement à Lui demander qu’Il me reçoive à merci mais aussi qu’Il
éclaire les malheureux qui fuient sa Face adorable…
Robert se transfigurait d’allégresse pieuse à recueillir ces paroles
par où s’avérait le salut du pauvre malade.
— Ah ! se disait-il, si elles pouvaient toucher le cœur de
Charles !…
Mais, celui-ci avait eu un mouvement de colère en entendant
Chériat proclamer la défaite de son orgueil. Il se détourna du lit et
fixa le plancher, devant lui, d’un air farouche.
Robert s’était agenouillé au chevet de Chériat.
L’un et l’autre se signèrent et, d’une inspiration spontanée, se
mirent à prier, à voix basse, pour leur ami perdu dans les ténèbres.
Tandis qu’ils appelaient sur lui la miséricorde du Seigneur,
Charles récapitulait, avec amertume et dérision, les propos des deux
croyants. Il tendait toutes les forces de son âme pour qu’elle rejetât
cette leçon de fraternité à l’égard d’autrui, d’humilité devant Dieu
qu’il venait de recevoir. Un instant, il avait été sur le point de fléchir ;
à présent encore, l’écho de l’Oraison Dominicale résonnait dans son
cœur. Mais il voulait que ce fût un bruit importun qu’il fallait se hâter
d’étouffer.
L’Évangile était près de lui, sur la table, ouvert au XIe chapitre de
Saint-Matthieu. Son regard s’y porta et il lut ceci :
Aimez vos ennemis, faites du bien à ceux qui vous haïssent et
priez pour ceux qui vous persécutent et vous calomnient, afin que
vous soyez les enfants de votre Père qui est dans les cieux, qui fait
lever son soleil sur les bons et les méchants et qui fait pleuvoir sur
les justes et les injustes.
— Encore le pardon ! murmura Charles qui sentait un étrange
courroux l’envahir de plus en plus. Il feuilleta quelques pages et
s’arrêta sur ce verset :
« Pierre, s’approchant du Seigneur, lui dit :
— Seigneur, combien de fois pardonnerai-je à mon frère, lorsqu’il
aura péché contre moi ? Sera-ce jusqu’à sept fois ?
Jésus lui dit :
— Je ne te dis pas jusqu’à sept fois, mais jusqu’à soixante-dix
fois sept fois… »
Charles ferma le livre d’un geste de mépris, et le repoussa loin
de lui.
— Voilà donc leur religion, pensa-t-il — et sa bouche se crispait
de dédain — : Souffrir avec patience, se résigner, se soumettre et,
par surcroît, faire du bien à ceux qui vous outragent… Morale
d’esclaves ! Et à supposer que leur Dieu existe, n’y aurait-il pas de la
grandeur à braver les préceptes de servilité qu’il impose aux cœurs
assez lâches pour lui obéir ?
Il se leva. Il lui semblait que son âme entière se raidissait en une
attitude de révolte, cependant que les clairons de l’orgueil lui
chantaient aux oreilles une furieuse fanfare.
D’une voix éclatante il cria :
— Je ne servirai pas !…
Ah ! c’était le non serviam de Lucifer, le sombre entêtement de
l’archange déchu, lorsque, précipité dans l’abîme, il releva sa tête où
fumait encore la marque de la foudre et refusa de se courber sous la
Main qui le châtiait…
A cette clameur, Abry et Chériat tressaillirent. Ils se tournèrent du
côté de Charles et l’envisagèrent avec une stupéfaction craintive.
— Mon Dieu, que t’arrive-t-il ? demanda Robert.
Charles eut un rire sarcastique :
— Si je te le dis, tu ne me comprendras sans doute pas. Et
pourtant, je veux que tu le saches : je ne pardonne pas à mes
ennemis moi ; je ne m’incline pas devant ton Dieu, moi ; je hais ceux
qui consentent à subir sa tyrannie. Ah ! je cherchais qui frapper. Eh
bien, ce sera justement les adorateurs de ton Dieu, les serviles qui,
comme toi, maintiennent, par leur douceur exécrable, une société
que je voudrais faire voler en éclats…
Robert frémit. Mais ces phrases forcenées, si elles le terrifiaient,
ne le firent pas reculer. Il sentait l’âme de son ami en proie au plus
extrême péril et il n’eut qu’une idée : l’arrêter sur la pente effroyable
où il roulait.
Il fit un pas en avant :
— Charles je t’en supplie, reviens à toi. Écoute-moi…
Mais l’autre, d’un geste coupant, le cloua sur place :
— Ne m’approche pas… Il y a un fossé entre nous, et ce fossé je
veux le remplir de sang… Ne m’approche pas, dis-je, je porte la
mort !
Et ce disant, il étreignait la bombe sur sa poitrine.
Chériat devina tout. Dressé d’épouvante, il s’écria :
— La bombe ! Il va jeter la bombe ; retiens-le…
Mais Charles avait gagné la porte. Du seuil, il se retourna et,
versant le feu par ses prunelles, il proféra : Oui, je vais jeter la
bombe.
Et savez-vous en quel endroit ? Sur l’autel même de ce Dieu dont
vous vous fabriquez un épouvantail. Nous verrons qui, de lui ou de
moi, sera le plus fort !…
Il sortit et, la seconde d’après, ils l’entendirent descendre
l’escalier quatre à quatre. Robert allait le suivre, le rattraper, lui
disputer l’engin, fût-ce au prix de sa propre existence. Mais Chériat,
tout suffoquant, venait de retomber sur l’oreiller. Une hémoptysie se
déclarait.
Robert courut au malade et lui prodiguant ses soins, tremblant
d’horreur et de désolation, il ne pouvait que répéter : Seigneur,
Seigneur, retenez son bras… Éclairez ce malheureux, il ne sait ce
qu’il fait !…
Et, à travers les hoquets lugubres qui lui soulevaient la poitrine,
Chériat disait :
— Mon Dieu, prenez-moi en rançon pour l’âme de cet infortuné ;
ne permettez pas que cette chose affreuse s’accomplisse…
CHAPITRE XIV

En janvier, le jour se lève tard. Six heures sonnaient lorsque


Charles se précipita dans la rue ; le temps s’était radouci ; il dégelait ;
mais une ombre brumeuse se traînait encore sur la ville. Un vent
mou passait par rafales, faisait vaciller les flammes des réverbères
et appliquait de larges gouttes de pluie sur le visage brûlant du
possédé.
Il descendit d’abord, presque en courant, le boulevard Saint-
Michel, mû par la crainte que Robert le rejoignît et tentât de lui
enlever la bombe — ce qui serait certainement arrivé sans le
crachement de sang de Chériat.
— S’il me suit, grondait-il, s’il veut me barrer le chemin, c’est lui
que je frapperai…
Il traversa la chaussée où des voitures de laitiers trottaient à
grand tapage et, s’adossant à la grille du square de Cluny, il surveilla
le trottoir opposé où il croyait toujours apercevoir Robert. Mais il n’y
avait que des tâcherons et des ouvrières qui se hâtaient vers leur
travail.
Rassuré, il repartit d’un pas plus lent. Il se disait seulement :
— J’entrerai dans la première église qui sera ouverte et là, je
lancerai la bombe soit sur quelque prêtre, soit parmi les individus
stupides qui s’y agenouillent, soit, au hasard, à travers le chœur. Le
tout, c’est qu’elle éclate comme un défi à ce Dieu en qui l’humanité
place ses lâches espoirs et son amour encore plus lâche de la
servitude. Si ce Dieu est une chimère, eh bien je lui mettrai du plomb
dans l’aile. Si, par grand hasard, il existe, je l’aurai bravé dans sa
maison. Oui cela vaut mieux que de supprimer Legranpan, Jacobin
tyrannique, ou de vagues bourgeois à l’abreuvoir…
Après je me laisserai arrêter sans résistance, Car il importe que
j’explique mon acte.
A la pensée de ce qu’il allait faire, son cœur se gonfla d’orgueil. Il
lui sembla qu’il dominait son époque et il éprouva un atroce bien-être
à se sentir inébranlable dans sa résolution.
Il arriva au bas du boulevard. Au lieu de traverser la Seine, il prit
machinalement à droite, longea le parapet du quai, enfila le Petit-
Pont et déboucha sur le Parvis. La façade et les tours de Notre-
Dame surgirent devant lui, dans le brouillard. On venait d’entr’ouvrir
le portail de gauche.
— Ah ! voici le but, s’exclama-t-il. Sans tergiverser, il franchit le
seuil, poussa la porte à ressort de l’intérieur et pénétra dans la
cathédrale.
Quel profond silence, quel calme auguste, quelle obscurité sainte
à peine interrompue par la faible clarté de la lampe qui scintille au
grand autel et par la lueur de petits cierges allumés çà et là.
Le contraste était trop fort entre le recueillement sacré de
l’immense basilique et le tumulte de rumeurs homicides qui
remplissaient l’âme de Charles. Il en subit l’impression et se sentit
comme intimidé. Mais réagissant aussitôt, il traversa la nef et se mit
à suivre le bas-côté qui mène à la sacristie.
Il alla jusqu’à la chapelle où s’élève le groupe de Saint-Georges
terrassant le démon. Là, il s’arrêta et s’accotant à un pilier, il
regarda.
Un vieux prêtre, servi par un seul enfant de chœur, célébrait la
Messe à côté du tombeau de Monseigneur Darboy. Cinq ou six
femmes du peuple, inclinées sur leur prie-dieu, s’unissaient avec
ferveur au Saint-Sacrifice. Charles, les bras croisés, la lèvre
dédaigneuse, ne quittait pas des yeux l’officiant.
Hésitait-il à l’imminence du crime ? — Point ; voici ce qu’il se
disait :
— Dans une minute, dès que ce vieil homme se retournera, je
lancerai la bombe. Et alors comme je jouirai de la panique de ces
sottes brebis laissées en détresse par leur Manitou !…
On commençait l’Offertoire. Le prêtre fit face aux fidèles, et les
mains ouvertes en signe de paix, il prononça :
— Que le Seigneur soit avec vous.
— Et avec ton esprit, murmurèrent l’enfant et les assistants.
Charles eut un geste pour saisir la bombe. Mais déjà le prêtre,
retourné vers le tabernacle, faisait l’offrande du pain et du vin.
— Après tout, se dit alors l’assassin, je n’ai pas besoin d’attendre
qu’il regarde de nouveau par ici… Assez de délais !
Il déboutonna son veston et tâta l’engin. Rien ne le retiendrait-il ?
— Au contraire, il avait la sensation qu’une invisible main lui poussait
le coude, tandis qu’une voix sardonique lui chuchotait :
— Va donc ! Va donc !…
Cependant le prêtre se purifiait les doigts et, juste comme
Charles mesurait la distance pour projeter la bombe, il récita le
verset tutélaire : Ne perdas cum impiis, Deus, animam meam, et
cum viris sanguinum vitam meam.
O Providence divine ; vous étiez là !
A ce moment, une étrange faiblesse fit retomber, désarmé, le
bras de l’homicide. Il y eut comme un mur d’airain qui se dressait
entre lui et l’autel. Il recula, balbutiant : Je ne peux pas !… Je ne
peux pas !… Ces pauvres femmes, cet enfant, ce vieillard en prière.
Oh ! non, c’est trop horrible. Je ne peux pas !…
Mais tout de suite, honteux d’avoir fléchi dans sa fureur, il se
donna un prétexte pour différer :
— Il n’y a pas assez de monde. Peut-être, tout à l’heure, y en
aura-t-il davantage. Je reviendrai…
Il s’éloigna rebroussant vers la sortie. Alors la voix démoniaque
reprit d’un accent furibond !
— Couard, tu cherches à ruser avec ta poltronnerie et tu traites
les autres de lâches ! Allons, reviens sur tes pas, frappe, tu seras
semblable à ce Dieu que tu redoutes…
Sur cette incitation, l’orgueil raidit tous les muscles de Charles. Il
lui parut qu’un torrent de feu lui coulait dans les veines.
— Soit ! répondit-il, que mon destin s’accomplisse…
Quand il proféra ces mots, il était sur le point de repasser le
portail. L’écume aux lèvres, il fit volte-face et poussa violemment la
porte intérieure afin de rentrer dans l’église. Puis il lâcha le bouton
pour ressaisir la bombe. Mais, dans la même seconde, le battant
actionné par le ressort, revint sur lui et le frappa d’un coup sec, en
pleine poitrine.
Un éclair rougeâtre jaillit, une détonation formidable roula sous
les voûtes séculaires, puis une âcre fumée remplit la cathédrale
jusqu’à l’abside…
Les premiers qui accoururent relevèrent le cadavre affreusement
mutilé de Charles : le torse était déchiré depuis le cou jusqu’au bas-
ventre ; les viscères hachés pendaient dans une mare de sang. La
main qui avait tenu la bombe avait été arrachée et projetée dehors,
sur le Parvis. La figure, restée intacte, exprimait une angoisse infinie
et l’on eût dit qu’un cri de terreur effroyable demeurait figé sur la
bouche béante…
Ainsi, par un évident miracle de la Justice divine, le meurtre
s’était retourné contre celui qui appelait le meurtre sur autrui.
ÉPILOGUE

L’attentat de Charles souleva une assez grande émotion dans


Paris.
Les fidèles, reconnaissant l’intervention de la Providence dans le
châtiment si prompt et si terrible de l’assassin, s’unirent pour rendre
grâces au Dieu d’équité qui a dit : « Je me suis réservé la
vengeance ».
Le peuple, qui garde du bon sens et des sentiments généreux
lorsque les sectaires qui l’exploitent ne le rendent point frénétique,
témoigna de l’horreur pour un assassin dont la barbarie avait failli
frapper des femmes sans défense. Les plus indulgents le plaignirent
comme un fou dont l’acte ne s’expliquait guère. D’autres — et ils
étaient nombreux — se sentirent troublés par les circonstances du
drame. Il se disait dans les ateliers :
— Pour sûr, c’est singulier qu’il se soit tué lui-même au moment
où il voulait chambarder Notre-Dame. Est-ce que, des fois, ce ne
seraient pas des blagues ce que racontent les calotins ? Y aurait-il
un Bon Dieu pour veiller sur nous ?
Cet état d’esprit prenant de l’extension, la Maçonnerie s’en
alarma et fit donner la presse athée. Divers journaux épiloguèrent à
l’infini sur les portes à ressort et le danger des explosifs maniés par
un agité. Le tout pour conclure à un hasard dont il fallait se féliciter
sans y reconnaître rien d’extraordinaire. Puis ils mirent les citoyens
en garde contre les manœuvres du « parti clérical » et ils insinuèrent
que les catholiques, lorsqu’ils affirmaient que la mort de Charles
prouvait, une fois de plus, l’existence du Surnaturel, méditaient de
rétablir l’Inquisition. Ensuite, ils couvrirent d’outrages le Cardinal-
archevêque qui s’était permis d’ordonner des prières expiatoires et
une cérémonie de purification de la Basilique où vint une foule
énorme. Bien entendu, ils rappelèrent, à ce propos, la révocation de
l’Édit de Nantes et la Saint-Barthélemy.
Enfin, pour faire entièrement diversion, ils organisèrent un défilé
des Loges devant la statue d’Étienne Dolet, ce précurseur dont la
libre-pensée alla jusqu’à l’uranisme.
Parmi les pauvres cervelles qui constituent ce que l’on baptise —
personne ne sait pourquoi — le grand monde, on éprouva d’abord
une frousse intense à la pensée que le meurtrier aurait pu jeter son
engin dans une paroisse élégante, à l’une de ces messes où les
gens du « dernier cri » font à Dieu l’honneur de venir s’ennuyer
pendant vingt minutes devant ses autels. Quelques caillettes chères
au Tout-Paris poussèrent des soupirs affectés et firent mine de
s’évanouir quand on parlait de Charles. Puis, comme un Juif fétide
mais fort millionnaire annonçait un grand bal, la « haute société » se
tourna toute vers un événement aussi considérable. On ne rêva plus
que de toilettes ébouriffantes et chacun se demanda s’il obtiendrait
la faveur d’une invitation à gigoter sous les regards chassieux de cet
Israélite.
L’explosion de la bombe ne surprit pas du tout Legranpan. Il
manda son chef de cabinet Lhiver et lui conta comment il avait
manqué, lui-même, d’être assassiné par le fils de Mandrillat. Puis,
songeant au désarroi où le Vénérable devait s’effondrer, il éclata de
ce rire en claquement de castagnettes archi-sèches dont il avait
coutume et dit :
— Du coup, voilà le banquet à l’eau, car vous comprenez bien,
Lhiver, que ce n’est pas le moment de repêcher ce pauvre Mandrillat
chu dans la mélasse par la faute de sa progéniture…
Mais ce qui importe, c’est d’exploiter la chose. Il faut détourner
l’attention des imbéciles de la Chambre qui espéraient se servir du
Maroc pour me flanquer à bas du pouvoir. Ah ! on dit qu’il y a des
fissures dans le Bloc : eh ! bien, nous allons les cimenter. Je fais
coffrer un certain nombre d’anarchistes et notamment les membres
du comité-directeur de la C. G. T. — Cela suscitera une interpellation
de l’Extrême-Gauche. Je monterai alors à la tribune : j’expliquerai
qu’en prenant cette mesure j’ai sauvé la République. Et je veux
devenir Pape si mes dindons radicaux et les bonnes poires du
Centre ne me votent pas, à une forte majorité, l’ordre du jour de
confiance que j’exigerai. Quant à ces messieurs de la Sociale, je
sais pertinemment, par les rapports de police, qu’ils ne sont pour
rien dans la stupide manifestation de Mandrillat junior. On les
relâchera donc dès que l’effet sera produit. S’ils braillent à
l’arbitraire, on leur collera une gratification pour leur Bourse du
travail ; cela leur fermera le bec…
Il en fut ainsi. Plusieurs révolutionnaires, dont Jourry, Sucre et
Greive, allèrent passer quelques jours à la Conciergerie. Le crime de
Charles les avait fort ennuyés car, comme tous les débitants de
drogues anarchistes, s’ils estimaient fort licite de prêcher l’impiété, le
vol et le massacre des « infâmes capitalistes », ils tremblaient dès
qu’un impatient de l’âge d’or promis par le socialisme appliquait
prématurément leur doctrine.
Charles ayant rompu avec eux, ils ne pouvaient se rendre
compte de l’inhumanité spéciale qui détermina le malheureux. C’est
pourquoi, sitôt remis en liberté, ils publièrent des articles où leur
ancien camarade était dénoncé, comme un agent provocateur que le
gouvernement avait soudoyé pour fournir un prétexte à leur
arrestation.
Le plus répugnant de tous fut Mandrillat.
Furieux et grotesque à la fois, il secouait sa femme qui se
permettait de verser quelques larmes, plutôt machinales, sur le
corps déchiré de leur enfant. Il lui défendit de prendre le deuil. Pour
le public, il se posa en Brutus et déclara aux reporters qui
assiégeaient sa porte que si son scélérat de fils avait survécu, il
l’aurait conduit de sa propre main à la guillotine.
Cet héroïsme lui valut une batterie d’honneur au Grand-Orient.
Mais ce fut tout. Il fit tant de tapage que Legranpan, agacé de le voir
revenir sans cesse sur un incident dont nul ne voulait plus entendre
parler parce qu’il provoquait trop de réflexions désagréables, lui
ordonna, d’une façon fort impérieuse, de se taire.
Mandrillat obéit et, pour faire peau neuve, entreprit un voyage en
Allemagne. Il s’y aboucha avec quelques financiers de Berlin et de
Francfort qui désiraient introduire des valeurs véreuses sur le
marché français. Le résultat fructueux de cette villégiature le consola
bien vite du déboire qu’il venait de subir.
Cependant la police avait fait une perquisition dans l’appartement
de la place Médicis. Elle ne trouva naturellement rien qui pût la
mettre sur la piste d’un complot puisque Charles avait agi de lui-
même et s’était gardé de se confier à personne. Chériat et Robert
interrogés ne purent que rapporter la tristesse farouche de leur ami
depuis des semaines et la façon dont il s’enfuit, malgré leurs efforts,
le matin où la bombe éclata. On ne les inquiéta point, car il était de
toute évidence qu’ils n’encouraient pas de responsabilité dans un
crime dont, jusqu’au dernier moment, ils avaient ignoré la
préparation.
Le seul indice qu’on découvrit des projets de Charles fut un
papier où il avait tracé, d’une main fébrile, ces mots : « L’homme
libre écarte les dogmes, les lois et tout ce qui entrave son droit à la
révolte. Il ne croit qu’en lui-même. Il frappe pour se grandir et il reste
sourd aux plaintes de ses victimes. C’est ainsi qu’il devient le
surhomme… »
Et maintenant Robert Abry, assisté de Madame Viard, qui était
accourue auprès de son frère, s’empressait autour du malade dont
l’état s’était aggravé du fait de la scène terrible qui précéda la mort
de Charles.
Enfin, à force de soins, Chériat se sentit un peu mieux. Mais si
ses souffrances corporelles avaient diminué, son esprit restait tout
anxieux.
Fixant sur Robert un regard de détresse, il dit :
— Mais comment, comment tout cela est-il arrivé ?… Comment
Charles a-t-il pu concevoir un dessein aussi épouvantable ?
— Ne parle pas, supplia la veuve, calme-toi, tu vas encore te
faire du mal…
— Eh bien je me tairai. Mais que Robert me rassure car je ne
comprends plus rien à rien et il me semble que je suis environné de
fantômes…
Robert était si profondément bouleversé qu’il ne réussit pas
d’abord à répondre. Dans son chagrin, il se demandait, lui aussi,
comment et pourquoi ? Et il se reprochait presque de n’avoir pas
deviné assez tôt le drame funèbre qui s’était déroulé dans l’âme de
son ami.
— Si j’avais insisté quand il vint rue d’Ulm, se disait-il, peut-être
m’aurait-il confié son affreux secret et aurais-je pu le fléchir… Il
courbait la tête, éperdu d’incertitude et se retenant pour ne pas
sangloter. Mais comme Chériat lui touchait le bras, d’un geste
suppliant, il fit un effort et dit d’une voix altérée :
— Avant tout, prions. Ce n’est qu’en sollicitant le secours d’En-
Haut que nous réussirons à échapper aux images sinistres qui nous
obsèdent.
— Oui, prions, répéta Mme Viard, qui s’agenouilla tandis que les
deux hommes joignaient les mains, prions la Sainte-Vierge. Jamais
nous n’avons eu plus besoin d’Elle puisqu’on la nomme, à juste titre,
la Consolatrice des affligés.
Par une inspiration spontanée, elle récita les litanies puis elle
proféra ce sublime appel à l’aide de la Grande-Auxiliatrice, le Sub
Tuum : Nous nous réfugions sous sa protection, Sainte Mère de
Dieu. Ne rejette pas la prière que nous t’adressons dans notre peine
excessive et garde-nous toujours de tout péril, ô Vierge de gloire et
de bénédiction…
A mesure qu’elle prononçait les saintes paroles, Robert se
rassérénait. Ainsi que bien d’autres fois, il vérifiait qu’on ne
s’adresse jamais en vain à Celle qui a reçu le pouvoir de réconforter
les cœurs trop éprouvés. La lumière se refit en lui et ce fut tout
enflammé d’une ardeur ineffable qu’à son tour, il récita le Memorare
de saint Bernard.
Quand il eut dit l’invocation finale : Noli, Mater Verbi, verba mea
despicere, sed audi, propitia et exaudi, son âme s’était reconquise.
De même, Chériat s’apaisait. Les ténèbres tragiques qui venaient
de descendre sur lui se dissipaient pour faire place à une aurore
angélique.
O Sainte Église, ce sont là les dictames que tu départis à tes
fidèles !…
— Ne prierons-nous pas aussi pour Charles, murmura-t-il, sa
pauvre âme, où est-elle à présent ?
— Certes approuva Robert, nous allons prier pour lui. Dieu est si
bon : je veux espérer qu’au moment suprême, il a permis que
l’infortuné ait une pensée de contrition.
— Et puis, reprit Chériat, rappelle-toi qu’il était charitable. Il m’a
recueilli mourant de misère. Presque tout son argent, il le donnait
aux pauvres… Louise Larbriselle peut en témoigner… Jusqu’au jour
où il devint si sombre et si méfiant, nul n’aurait pu le taxer de
perversité. Comme tant d’autres, comme moi-même avant que
Notre-Seigneur m’éclairât, il vivait dans l’erreur mais il était de bonne
foi. Où aurait-il appris à se garder du mal ? Ce n’est pas dans le
milieu où il fut élevé puisque, nous le savons, on s’est appliqué à lui
nourrir l’esprit d’athéisme et d’orgueil.
— Il m’a demandé de prier pour lui, dit Mme Viard en pleurant.
— Oui, conclut Robert, la Justice divine qui, seule, est infaillible,
pèsera tout cela dans sa balance. Mais ce qui me fait frissonner
c’est que je réfléchis qu’ils sont des milliers à présent, dans notre
pauvre pays, qui subissent une éducation analogue à celle de
Charles. On ne veut plus de Dieu ; on fait le vide dans les âmes.
Puis l’on s’étonne que le démon s’y installe à la place de ce Dieu
qu’on jette à la voirie parmi les outrages et les crachats… Je sais : il
est de mode de sourire lorsqu’un croyant affirme que le diable
s’empare de nous dès que nous nous détournons de l’Église.
Pour expliquer les crimes qui se multiplient, la frénésie de
jouissance, l’inquiétude sans but qui possèdent tant de nos
contemporains, la Science, pauvre folle infatuée d’elle-même, bat les
buissons çà et là, bâtit cent systèmes, cent châteaux de sable
qu’elle n’édifie que pour les renverser la minute d’après et pour
courir à de nouvelles illusions. Des philosophies se hissent sur des
piédestaux branlants et affirment que l’homme n’est qu’une
mécanique instable mue par des forces aveugles et que le bonheur
consiste à satisfaire ses pulsions jusqu’à la satiété. On instaure le
règne de la Bête d’après cette maxime : « La vie est un cauchemar
entre deux néants. » Pour l’oublier régalons nos instincts !
Cependant le démon verse les ténèbres du désespoir dans l’âme
des sensitifs et des douloureux qu’une telle odieuse doctrine ne suffit
pas à contenter. La France est ivre d’impiété ; par suite le nombre ne
cesse de s’accroître de ceux qui, comme notre ami, tombent sous le
joug du Mauvais parce que nul ne les avertit que, seule, notre sainte
religion peut les en préserver. Hélas, ils se disent libres ; et on les
força d’ignorer qu’en rejetant, comme une lisière importune, la
sauvegarde de la foi, ils se soumettent au plus irrémissible des
esclavages : celui du péché.
Ah ! prions, prions pour Charles. Prions aussi pour la France,
supplions le Seigneur d’avoir pitié de nous.
Et suivi par la veuve et le malade, il dit humblement les versets
du De profundis :

« Des profondeurs de l’abîme, nous crions vers toi, Seigneur.


Seigneur, écoute notre voix.
« Que tes oreilles se rendent attentives à la voix de notre
déprécation.
« Si tu observes nos iniquités, Seigneur, qui de nous soutiendra
ton regard ?
« Mais parce que la miséricorde est en toi, Seigneur, j’espère à
cause de ta loi.
« Mon âme se confie en ton verbe ; mon âme espère dans le
Seigneur.
« Depuis la vigile du matin jusqu’à la nuit, que ton peuple espère
en toi, Seigneur.
« Parce que la miséricorde appartient au Seigneur et qu’auprès
de lui la rédemption est abondante.
« Et lui-même rachètera son peuple de toutes les iniquités.
« Seigneur donne aux âmes des morts le repos éternel et fais
luire sur eux ta lumière sans fin.
« Qu’ils reposent en paix. — Ainsi soit-il. »

Tous trois s’embrassèrent. Puis Robert, debout et les yeux au


ciel, reprit :
— Seigneur, nous ne sommes rien sans ton secours. S’il est
dans tes desseins que nous périssions, que ta volonté s’accomplisse
et non la nôtre. Mais, ô mon Dieu, si pour sauver notre France qui se
détourne de ta Face, il est besoin de victimes expiatoires, nous voici
prêts à souffrir pour que ton Nom soit sanctifié, pour que ton règne
arrive.
Pour les folies et les péchés des égarés qui te défient, l’injure et
le sarcasme à la bouche, nous nous offrons à ta colère. Toi,
cependant, ramène-les dans tes voies ; distribue-leur le pain
suprasubstantiel : ta parole immuable.
Comme il nous fut prescrit par ton Fils, nous leur pardonnons,
sans arrière-pensée, sans restrictions vindicatives, les persécutions
qu’ils infligent à ton Église. De même, ne les traite pas d’après
l’énormité de leur ingratitude envers toi, mais considère leur
aveuglement.
Par l’incarnation de ton Fils, par ses souffrances et ses plaies,
par la Croix qui ne cesse d’étendre sur le monde ses bras
rédempteurs, par ta Sainte-Mère, refuge des pécheurs, appui des
malheureux, étoile du matin, arche de ton alliance avec nous, par les
mérites de tous les Saints qui combattirent et triomphèrent pour ta
gloire, accueille notre supplication ; fais cesser cette trop longue
tentation. Libère la France du démon d’orgueil qui l’opprime ; délivre-
nous du mal. Ainsi soit-il.
D’un même élan, tous trois répétèrent :
— O Dieu le Père, qui es la Justice, ô Dieu le Fils, qui es l’Amour,
ô Dieu le Saint-Esprit qui es la Grâce, Sainte-Trinité, un seul Dieu,
libère la France du démon qui l’opprime, délivre nous du mal…
Et longtemps, agenouillés côte à côte, ils demeurèrent en
oraison, selon l’esprit de la Sainte-Église catholique, en dehors de
laquelle il n’y a ni lumière, ni vérité, ni consolation, ni salut.

Benevolens lector, in nomine


Domini, ora pro scriptore.

Fin

Note. — L’auteur croit devoir rappeler que pour l’explosion qui termine le livre
par la mort de Charles, il n’a rien inventé.
En effet, les choses se passèrent exactement telles quelles à l’église de la
Madeleine en 1894.
L’auteur n’a fait que transposer l’événement à Notre-Dame.

Saint-Amand, Cher. — Imprimerie BUSSIÈRE.


*** END OF THE PROJECT GUTENBERG EBOOK LE RÈGNE DE
LA BÊTE ***

Updated editions will replace the previous one—the old editions will
be renamed.

Creating the works from print editions not protected by U.S.


copyright law means that no one owns a United States copyright in
these works, so the Foundation (and you!) can copy and distribute it
in the United States without permission and without paying copyright
royalties. Special rules, set forth in the General Terms of Use part of
this license, apply to copying and distributing Project Gutenberg™
electronic works to protect the PROJECT GUTENBERG™ concept
and trademark. Project Gutenberg is a registered trademark, and
may not be used if you charge for an eBook, except by following the
terms of the trademark license, including paying royalties for use of
the Project Gutenberg trademark. If you do not charge anything for
copies of this eBook, complying with the trademark license is very
easy. You may use this eBook for nearly any purpose such as
creation of derivative works, reports, performances and research.
Project Gutenberg eBooks may be modified and printed and given
away—you may do practically ANYTHING in the United States with
eBooks not protected by U.S. copyright law. Redistribution is subject
to the trademark license, especially commercial redistribution.

START: FULL LICENSE


THE FULL PROJECT GUTENBERG LICENSE
PLEASE READ THIS BEFORE YOU DISTRIBUTE OR USE THIS WORK

To protect the Project Gutenberg™ mission of promoting the free


distribution of electronic works, by using or distributing this work (or
any other work associated in any way with the phrase “Project
Gutenberg”), you agree to comply with all the terms of the Full
Project Gutenberg™ License available with this file or online at
www.gutenberg.org/license.

Section 1. General Terms of Use and


Redistributing Project Gutenberg™
electronic works
1.A. By reading or using any part of this Project Gutenberg™
electronic work, you indicate that you have read, understand, agree
to and accept all the terms of this license and intellectual property
(trademark/copyright) agreement. If you do not agree to abide by all
the terms of this agreement, you must cease using and return or
destroy all copies of Project Gutenberg™ electronic works in your
possession. If you paid a fee for obtaining a copy of or access to a
Project Gutenberg™ electronic work and you do not agree to be
bound by the terms of this agreement, you may obtain a refund from
the person or entity to whom you paid the fee as set forth in
paragraph 1.E.8.

1.B. “Project Gutenberg” is a registered trademark. It may only be


used on or associated in any way with an electronic work by people
who agree to be bound by the terms of this agreement. There are a
few things that you can do with most Project Gutenberg™ electronic
works even without complying with the full terms of this agreement.
See paragraph 1.C below. There are a lot of things you can do with
Project Gutenberg™ electronic works if you follow the terms of this
agreement and help preserve free future access to Project
Gutenberg™ electronic works. See paragraph 1.E below.

You might also like