100% found this document useful (1 vote)
69 views

Data Analysis in Medicine and Health Using R Kamarul Imran Musa instant download

The document discusses the book 'Data Analysis in Medicine and Health Using R' by Kamarul Imran Musa and others, which aims to equip healthcare professionals with essential data analysis and statistical skills using the R programming language. It emphasizes the importance of reproducible data analysis in medicine and provides resources such as R codes and datasets available on GitHub. Additionally, the book is part of a series focused on analytics and AI in healthcare, addressing various applications in the field.

Uploaded by

cahetenivre63
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (1 vote)
69 views

Data Analysis in Medicine and Health Using R Kamarul Imran Musa instant download

The document discusses the book 'Data Analysis in Medicine and Health Using R' by Kamarul Imran Musa and others, which aims to equip healthcare professionals with essential data analysis and statistical skills using the R programming language. It emphasizes the importance of reproducible data analysis in medicine and provides resources such as R codes and datasets available on GitHub. Additionally, the book is part of a series focused on analytics and AI in healthcare, addressing various applications in the field.

Uploaded by

cahetenivre63
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 42

Data Analysis in Medicine and Health Using R

Kamarul Imran Musa pdf download

https://ebookmeta.com/product/data-analysis-in-medicine-and-
health-using-r-kamarul-imran-musa/

Download more ebook from https://ebookmeta.com


We believe these products will be a great fit for you. Click
the link to download now, or visit ebookmeta.com
to discover even more!

A Primer in Biological Data Analysis and Visualization


Using R 2nd Edition Gregg Hartvigsen

https://ebookmeta.com/product/a-primer-in-biological-data-
analysis-and-visualization-using-r-2nd-edition-gregg-hartvigsen/

Data Science and Predictive Analytics: Biomedical and


Health Applications using R, 2nd 2nd Edition Ivo D.
Dinov

https://ebookmeta.com/product/data-science-and-predictive-
analytics-biomedical-and-health-applications-using-r-2nd-2nd-
edition-ivo-d-dinov/

Imaging Life: Image Acquisition and Analysis in Biology


and Medicine Lawrence R. Griffing

https://ebookmeta.com/product/imaging-life-image-acquisition-and-
analysis-in-biology-and-medicine-lawrence-r-griffing/

Nonprofit Bookkeeping & Accounting For Dummies (For


Dummies (Business & Personal Finance)) 2nd Edition
Loughran

https://ebookmeta.com/product/nonprofit-bookkeeping-accounting-
for-dummies-for-dummies-business-personal-finance-2nd-edition-
loughran/
Journey with Muhammad Prophecy in Ismaili Gnosis 1st
Edition Aziz Talbani

https://ebookmeta.com/product/journey-with-muhammad-prophecy-in-
ismaili-gnosis-1st-edition-aziz-talbani/

Gabriel Mafia Academy 3 1st Edition Holly S. Roberts

https://ebookmeta.com/product/gabriel-mafia-academy-3-1st-
edition-holly-s-roberts/

The New Seattle Cookbook Discover Delicious West Coast


Meals from the Heart of Seattle 2nd Edition Unknown

https://ebookmeta.com/product/the-new-seattle-cookbook-discover-
delicious-west-coast-meals-from-the-heart-of-seattle-2nd-edition-
unknown/

Covid-19 in Asia: Law and Policy Contexts 1st Edition


Victor V. Ramraj

https://ebookmeta.com/product/covid-19-in-asia-law-and-policy-
contexts-1st-edition-victor-v-ramraj/

Recommender Systems The Textbook Aggarwal

https://ebookmeta.com/product/recommender-systems-the-textbook-
aggarwal/
Farewell Mr Lovely Working Stiffs Mystery 9 1st Edition
Wendy Delaney

https://ebookmeta.com/product/farewell-mr-lovely-working-stiffs-
mystery-9-1st-edition-wendy-delaney/
Data Analysis in
Medicine and Health
Using R

In medicine and health, data are analyzed to guide treatment plans, patient care
and control and prevention policies. However, in doing so, researchers in medi-
cine and health often lack the understanding of data and statistical concepts and
the skills in programming. In addition, there is also an increasing demand for data
analyses to be reproducible, along with more complex data that require cutting-
edge analysis. This book provides readers with both the fundamental concepts
of data and statistical analysis and modeling. It also has the skills to perform the
analysis using the R programming language, which is the lingua franca for statis-
ticians. The topics in the book are presented in a sequence to minimize the time
to help readers understand the objectives of data and statistical analysis, learn
the concepts of statistical modeling and acquire the skills to perform the analysis.
The R codes and datasets used in the book will be made available on GitHub for
easy access. The book will also be live on the website bookdown.org, a service
provided by RStudio, PBC, to host books written using the bookdown package in
the R programming language.
Analytics and AI for Healthcare

Series Editor: Nilmini Wickramasinghe, Swinburne University of Technology

About the Series


Artificial Intelligence (AI) and analytics are increasingly being applied to various health-
care settings. AI and analytics are salient to facilitate better understanding and identifying
key insights from healthcare data in many areas of practice and enquiry in healthcare in-
cluding at the genomic, individual, hospital, community and/or population levels.

The Chapman & Hall/CRC Press Analytics and AI in Healthcare Series aims to help pro-
fessionals upskill and leverage the techniques, tools, technologies and tactics of analytics
and AI to achieve better healthcare delivery, access and outcomes.

The series covers all areas of analytics and AI as applied to healthcare. It will look at critical
areas, including prevention, prediction, diagnosis, treatment, monitoring, rehabilitation
and survivorship.

Explainable Artificial Intelligence in Healthcare: Unboxing Machine Learning in Pre-pro-


cessing and Medical Imaging
Edited by Mehul S Raval, Mohendra Roy, Tolga Kaya, and Rupal Kapdi

Data Analysis in Medicine and Health Using R


Kamarul Imran Musa, Wan Nor Arifin Wan Mansor, and Tengku Muhammad Hanis

For more information about this series please visit: https://www.routledge.com/analytics-


and-ai-for-healthcare/book-series/Aforhealth
Data Analysis in
Medicine and Health
Using R

Kamarul Imran Musa


Wan Nor Arifin Wan Mansor
Tengku Muhammad Hanis
First edition published 2024
by CRC Press
6000 Broken Sound Parkway NW, Suite 300, Boca Raton, FL 33487-2742

and by CRC Press


4 Park Square, Milton Park, Abingdon, Oxon, OX14 4RN

CRC Press is an imprint of Taylor & Francis Group, LLC

© 2024 Kamarul Imran Musa, Wan Nor Arifin Wan Mansor, and Tengku Muhammad Hanis

Reasonable efforts have been made to publish reliable data and information, but the author and pub-
lisher cannot assume responsibility for the validity 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 utilized in any form by any electronic, mechanical, or other means, now known or
hereafter invented, including photocopying, microfilming, and recording, or in any information stor-
age or retrieval system, without written permission from the publishers.

For permission to photocopy or use material electronically from this work, access www.copyright.
com or contact the Copyright Clearance Center, Inc. (CCC), 222 Rosewood Drive, Danvers, MA
01923, 978-750-8400. For works that are not available on CCC please contact mpkbookspermis-
[email protected]

Trademark notice: Product or corporate names may be trademarks or registered trademarks and are
used only for identification and explanation without intent to infringe.

ISBN: 978-1-032-28415-6 (hbk)


ISBN: 978-1-032-28414-9 (pbk)
ISBN: 978-1-003-29677-5 (ebk)

DOI: 10.1201/9781003296775
Typeset in Alegreya font
by KnowledgeWorks Global Ltd

Publisher’s note: This book has been prepared from camera-ready copy provided by the authors.
Kamarul Imran Musa (KIM) would like to dedicate this book to his parents (Arwah
Hj Musa and Napisah Mohamed Nor) and his parents-in-law, his wife (Juhara
Haron), his sons (Afif and Iman) and to all his students.
Wan Nor Arifin Wan Mansor (WNA) would like to dedicate this book to researchers
in medicine, public health and health sciences who are brave enough to learn R.
You are the heroes of the future!
Tengku Muhammad Hanis would like to dedicate this book to his parents (Tengku
Mokhtar and Nor Malaysia), his wife (Nurul Asmaq) and all his fantastic teachers
and lecturers.
Contents

Preface xv

1 R, RStudio and RStudio Cloud 1


1.1 Objectives . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
1.2 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
1.3 RStudio IDE . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
1.4 RStudio Cloud . . . . . . . . . . . . . . . . . . . . . . . . . . 2
1.4.1 The RStudio Cloud registration . . . . . . . . . . . . . . 3
1.4.2 Register and log in . . . . . . . . . . . . . . . . . . . . 3
1.5 Point and Click Graphical User Interface (GUI) . . . . . . . . . . 4
1.6 RStudio Server . . . . . . . . . . . . . . . . . . . . . . . . . . 5
1.7 Installing R and RStudio on Your Local Machine . . . . . . . . . 6
1.7.1 Installing R . . . . . . . . . . . . . . . . . . . . . . . . 6
1.7.2 Installing RStudio IDE . . . . . . . . . . . . . . . . . . 6
1.7.3 Checking R and RStudio installations . . . . . . . . . . . 7
1.7.4 TinyTeX, MiKTeX or MacTeX (for Mac OS) and TeX live . . 8
1.8 Starting Your RStudio . . . . . . . . . . . . . . . . . . . . . . 9
1.8.1 Console tab . . . . . . . . . . . . . . . . . . . . . . . . 10
1.8.2 Files, plots, packages, help and viewer pane . . . . . . . . 11
1.8.3 Environment, history, connection and build pane . . . . . 12
1.8.4 Source pane . . . . . . . . . . . . . . . . . . . . . . . . 12
1.9 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13

2 R Scripts and R Packages 15


2.1 Objectives . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
2.2 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
2.3 Open a New Script . . . . . . . . . . . . . . . . . . . . . . . . 15
2.3.1 Our first R script . . . . . . . . . . . . . . . . . . . . . 16
2.3.2 Function, argument and parameters . . . . . . . . . . . 17
2.3.3 If users require further help . . . . . . . . . . . . . . . . 18
2.4 Packages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
2.4.1 Packages on CRAN . . . . . . . . . . . . . . . . . . . . 19
2.4.2 Checking availability of R package . . . . . . . . . . . . . 20
2.4.3 Install an R package . . . . . . . . . . . . . . . . . . . . 20
2.5 Working Directory . . . . . . . . . . . . . . . . . . . . . . . . 22
2.5.1 Starting a new R job . . . . . . . . . . . . . . . . . . . . 22

vii
viii Contents

2.5.2 Creating a new R project . . . . . . . . . . . . . . . . . 22


2.5.3 Location for dataset . . . . . . . . . . . . . . . . . . . . 22
2.6 Upload Data to RStudio Cloud . . . . . . . . . . . . . . . . . . 23
2.7 More Resources on RStudio Cloud . . . . . . . . . . . . . . . . 25
2.8 Guidance and Help . . . . . . . . . . . . . . . . . . . . . . . . 25
2.9 Bookdown . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
2.10 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26

3 RStudio Project 27
3.1 Objectives . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
3.2 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
3.3 Dataset Repository on GitHub . . . . . . . . . . . . . . . . . . 28
3.4 RStudio Project on RStudio or Posit Cloud . . . . . . . . . . . . 29
3.5 RStudio Project on Local Machine . . . . . . . . . . . . . . . . . 32
3.6 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35

4 Data Visualization 37
4.1 Objectives . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37
4.2 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . 37
4.3 History and Objectives of Data Visualization . . . . . . . . . . . 38
4.4 Ingredients for Good Graphics . . . . . . . . . . . . . . . . . . 38
4.5 Graphics Packages in R . . . . . . . . . . . . . . . . . . . . . . 38
4.6 The ggplot2 Package . . . . . . . . . . . . . . . . . . . . . . . 39
4.7 Preparation . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40
4.7.1 Create a new RStudio project . . . . . . . . . . . . . . . 40
4.7.2 Important questions before plotting graphs . . . . . . . . 40
4.8 Read Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41
4.9 Load the Packages . . . . . . . . . . . . . . . . . . . . . . . . 41
4.10 Read the Dataset . . . . . . . . . . . . . . . . . . . . . . . . . 43
4.11 Basic Plots . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45
4.12 More Complex Plots . . . . . . . . . . . . . . . . . . . . . . . 46
4.12.1 Adding another variable . . . . . . . . . . . . . . . . . . 46
4.12.2 Making subplots . . . . . . . . . . . . . . . . . . . . . 50
4.12.3 Overlaying plots . . . . . . . . . . . . . . . . . . . . . . 51
4.12.4 Combining different plots . . . . . . . . . . . . . . . . . 55
4.12.5 Statistical transformation . . . . . . . . . . . . . . . . . 60
4.12.6 Customizing title . . . . . . . . . . . . . . . . . . . . . 62
4.12.7 Choosing themes . . . . . . . . . . . . . . . . . . . . . 65
4.12.8 Adjusting axes . . . . . . . . . . . . . . . . . . . . . . 66
4.13 Saving Plots . . . . . . . . . . . . . . . . . . . . . . . . . . . 69
4.14 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 72

5 Data Wrangling 73
5.1 Objectives . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73
5.2 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . 73
Contents ix

5.2.1 Definition of data wrangling . . . . . . . . . . . . . . . 73


5.3 Data Wrangling with dplyr Package . . . . . . . . . . . . . . . . 74
5.3.1 dplyr package . . . . . . . . . . . . . . . . . . . . . . . 74
5.3.2 Common data wrangling processes . . . . . . . . . . . . 74
5.3.3 Some dplyr functions . . . . . . . . . . . . . . . . . . . 74
5.4 Preparation . . . . . . . . . . . . . . . . . . . . . . . . . . . . 75
5.4.1 Create a new project or set the working directory . . . . . 75
5.4.2 Load the libraries . . . . . . . . . . . . . . . . . . . . . 75
5.4.3 Datasets . . . . . . . . . . . . . . . . . . . . . . . . . 76
5.5 Select Variables, Generate New Variable and Rename Variable . . . 80
5.5.1 Select variables using dplyr::select() . . . . . . . . . . . 80
5.5.2 Generate new variable using mutate() . . . . . . . . . . . 81
5.5.3 Rename variable using rename() . . . . . . . . . . . . . . 82
5.6 Sorting Data and Selecting Observation . . . . . . . . . . . . . . 82
5.6.1 Sorting data using arrange() . . . . . . . . . . . . . . . . 82
5.6.2 Select observation using filter() . . . . . . . . . . . . . 83
5.7 Group Data and Get Summary Statistics . . . . . . . . . . . . . 84
5.7.1 Group data using group_by() . . . . . . . . . . . . . . . . 84
5.7.2 Summary statistic using summarize() . . . . . . . . . . . 84
5.8 More Complicated dplyr Verbs . . . . . . . . . . . . . . . . . . 85
5.9 Data Transformation for Categorical Variables . . . . . . . . . . 86
5.9.1 forcats package . . . . . . . . . . . . . . . . . . . . . . 86
5.9.2 Conversion from numeric to factor variables . . . . . . . 86
5.9.3 Recoding variables . . . . . . . . . . . . . . . . . . . . 87
5.9.4 Changing the level of categorical variable . . . . . . . . . 87
5.10 Additional Resources . . . . . . . . . . . . . . . . . . . . . . . 88
5.11 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 89

6 Exploratory Data Analysis 91


6.1 Objectives . . . . . . . . . . . . . . . . . . . . . . . . . . . . 91
6.2 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . 91
6.3 EDA Using ggplot2 Package . . . . . . . . . . . . . . . . . . . . 92
6.3.1 Usage of ggplot2 . . . . . . . . . . . . . . . . . . . . . 92
6.4 Preparation . . . . . . . . . . . . . . . . . . . . . . . . . . . . 92
6.4.1 Load the libraries . . . . . . . . . . . . . . . . . . . . . 92
6.4.2 Read the dataset into R . . . . . . . . . . . . . . . . . . 93
6.5 EDA in Tables . . . . . . . . . . . . . . . . . . . . . . . . . . . 94
6.6 EDA with Plots . . . . . . . . . . . . . . . . . . . . . . . . . . 98
6.6.1 One variable: Distribution of a categorical variable . . . . 98
6.6.2 One variable: Distribution of a numerical variable . . . . . 101
6.6.3 Two variables: Plotting a numerical and a categorical
variable . . . . . . . . . . . . . . . . . . . . . . . . . . 103
6.6.4 Three variables: Plotting a numerical and two categorical
variables . . . . . . . . . . . . . . . . . . . . . . . . . 105
6.6.5 Faceting the plots . . . . . . . . . . . . . . . . . . . . . 105
x Contents

6.6.6 Line plot . . . . . . . . . . . . . . . . . . . . . . . . . 107


6.6.7 Plotting means and error bars . . . . . . . . . . . . . . . 109
6.6.8 Scatterplot with fit line . . . . . . . . . . . . . . . . . . 111
6.7 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 113

7 Linear Regression 115


7.1 Objectives . . . . . . . . . . . . . . . . . . . . . . . . . . . . 115
7.2 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . 115
7.3 Linear Regression Models . . . . . . . . . . . . . . . . . . . . . 115
7.4 Prepare R Environment for Analysis . . . . . . . . . . . . . . . 116
7.4.1 Libraries . . . . . . . . . . . . . . . . . . . . . . . . . 116
7.4.2 Dataset . . . . . . . . . . . . . . . . . . . . . . . . . . 116
7.5 Simple Linear Regression . . . . . . . . . . . . . . . . . . . . . 118
7.5.1 About simple linear regression . . . . . . . . . . . . . . 118
7.5.2 Data exploration . . . . . . . . . . . . . . . . . . . . . 118
7.5.3 Univariable analysis . . . . . . . . . . . . . . . . . . . . 119
7.5.4 Model fit assessment . . . . . . . . . . . . . . . . . . . 120
7.5.5 Presentation and interpretation . . . . . . . . . . . . . . 122
7.6 Multiple Linear Regression . . . . . . . . . . . . . . . . . . . . 122
7.6.1 About multiple linear regression . . . . . . . . . . . . . . 122
7.6.2 Data exploration . . . . . . . . . . . . . . . . . . . . . 123
7.6.3 Univariable analysis . . . . . . . . . . . . . . . . . . . . 124
7.6.4 Multivariable analysis . . . . . . . . . . . . . . . . . . . 125
7.6.5 Interaction . . . . . . . . . . . . . . . . . . . . . . . . 130
7.6.6 Model fit assessment . . . . . . . . . . . . . . . . . . . 131
7.6.7 Presentation and interpretation . . . . . . . . . . . . . . 133
7.7 Prediction . . . . . . . . . . . . . . . . . . . . . . . . . . . . 135
7.8 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 136

8 Binary Logistic Regression 137


8.1 Objectives . . . . . . . . . . . . . . . . . . . . . . . . . . . . 137
8.2 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . 137
8.3 Logistic Regression Model . . . . . . . . . . . . . . . . . . . . 138
8.4 Dataset . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 138
8.5 Logit and Logistic Models . . . . . . . . . . . . . . . . . . . . . 138
8.6 Prepare Environment for Analysis . . . . . . . . . . . . . . . . . 139
8.6.1 Creating a RStudio project . . . . . . . . . . . . . . . . 139
8.6.2 Loading libraries . . . . . . . . . . . . . . . . . . . . . 140
8.7 Read Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . 141
8.8 Explore Data . . . . . . . . . . . . . . . . . . . . . . . . . . . 141
8.9 Estimate the Regression Parameters . . . . . . . . . . . . . . . 143
8.10 Simple Binary Logistic Regression . . . . . . . . . . . . . . . . 143
8.11 Multiple Binary Logistic Regression . . . . . . . . . . . . . . . . 146
8.12 Convert the Log Odds to Odds Ratio . . . . . . . . . . . . . . . 148
8.13 Making Inference . . . . . . . . . . . . . . . . . . . . . . . . . 148
Contents xi

8.14 Models Comparison . . . . . . . . . . . . . . . . . . . . . . . 150


8.15 Adding an Interaction Term . . . . . . . . . . . . . . . . . . . 151
8.16 Prediction from Binary Logistic Regression . . . . . . . . . . . . 152
8.16.1 Predict the log odds . . . . . . . . . . . . . . . . . . . . 153
8.16.2 Predict the probabilities . . . . . . . . . . . . . . . . . . 153
8.17 Model Fitness . . . . . . . . . . . . . . . . . . . . . . . . . . . 154
8.18 Presentation of Logistic Regression Model . . . . . . . . . . . . 156
8.19 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 156

9 Multinomial Logistic Regression 159


9.1 Objectives . . . . . . . . . . . . . . . . . . . . . . . . . . . . 159
9.2 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . 159
9.3 Examples of Multinomial Outcome Variables . . . . . . . . . . . 160
9.4 Models for Multinomial Outcome Data . . . . . . . . . . . . . . 160
9.5 Estimation for Multinomial Logit Model . . . . . . . . . . . . . 161
9.5.1 Log odds and odds ratios . . . . . . . . . . . . . . . . . 161
9.5.2 Conditional probabilities . . . . . . . . . . . . . . . . . 162
9.6 Prepare Environment . . . . . . . . . . . . . . . . . . . . . . . 162
9.6.1 Load libraries . . . . . . . . . . . . . . . . . . . . . . . 162
9.6.2 Dataset . . . . . . . . . . . . . . . . . . . . . . . . . . 164
9.6.3 Read data . . . . . . . . . . . . . . . . . . . . . . . . . 164
9.6.4 Data wrangling . . . . . . . . . . . . . . . . . . . . . . 165
9.6.5 Create new categorical variable from fbs . . . . . . . . . . 165
9.6.6 Exploratory data analysis . . . . . . . . . . . . . . . . . 166
9.6.7 Confirm the order of cat_fbs . . . . . . . . . . . . . . . 167
9.7 Estimation . . . . . . . . . . . . . . . . . . . . . . . . . . . . 168
9.7.1 Single independent variable . . . . . . . . . . . . . . . . 168
9.7.2 Multiple independent variables . . . . . . . . . . . . . . 170
9.7.3 Model with interaction term between independent variables 171
9.8 Inferences . . . . . . . . . . . . . . . . . . . . . . . . . . . . 172
9.9 Interpretation . . . . . . . . . . . . . . . . . . . . . . . . . . 174
9.10 Prediction . . . . . . . . . . . . . . . . . . . . . . . . . . . . 174
9.11 Presentation of Multinomial Regression Model . . . . . . . . . . 175
9.12 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 175

10 Poisson Regression 177


10.1 Objectives . . . . . . . . . . . . . . . . . . . . . . . . . . . . 177
10.2 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . 177
10.3 Prepare R Environment for Analysis . . . . . . . . . . . . . . . 179
10.3.1 Libraries . . . . . . . . . . . . . . . . . . . . . . . . . 179
10.4 Poisson Regression for Count . . . . . . . . . . . . . . . . . . . 179
10.4.1 About Poisson regression for count . . . . . . . . . . . . 179
10.4.2 Dataset . . . . . . . . . . . . . . . . . . . . . . . . . . 180
10.4.3 Data exploration . . . . . . . . . . . . . . . . . . . . . 180
10.4.4 Univariable analysis . . . . . . . . . . . . . . . . . . . . 181
xii Contents

10.4.5 Multivariable analysis . . . . . . . . . . . . . . . . . . . 183


10.4.6 Interaction . . . . . . . . . . . . . . . . . . . . . . . . 185
10.4.7 Model fit assessment . . . . . . . . . . . . . . . . . . . 186
10.4.8 Presentation and interpretation . . . . . . . . . . . . . . 188
10.4.9 Prediction . . . . . . . . . . . . . . . . . . . . . . . . . 192
10.5 Poisson Regression for Rate . . . . . . . . . . . . . . . . . . . . 193
10.5.1 About Poisson regression for rate . . . . . . . . . . . . . 193
10.5.2 Dataset . . . . . . . . . . . . . . . . . . . . . . . . . . 193
10.5.3 Data exploration . . . . . . . . . . . . . . . . . . . . . 194
10.5.4 Univariable analysis . . . . . . . . . . . . . . . . . . . . 196
10.5.5 Multivariable analysis . . . . . . . . . . . . . . . . . . . 198
10.5.6 Interaction . . . . . . . . . . . . . . . . . . . . . . . . 199
10.5.7 Model fit assessment . . . . . . . . . . . . . . . . . . . 200
10.5.8 Presentation and interpretation . . . . . . . . . . . . . . 201
10.6 Quasi-Poisson Regression for Overdispersed Data . . . . . . . . 204
10.7 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 205

11 Survival Analysis: Kaplan–Meier and Cox Proportional Hazard (PH)


Regression 207
11.1 Objectives . . . . . . . . . . . . . . . . . . . . . . . . . . . . 207
11.2 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . 207
11.3 Types of Survival Analysis . . . . . . . . . . . . . . . . . . . . . 208
11.4 Prepare Environment for Analysis . . . . . . . . . . . . . . . . . 208
11.4.1 RStudio project . . . . . . . . . . . . . . . . . . . . . . 208
11.4.2 Packages . . . . . . . . . . . . . . . . . . . . . . . . . 209
11.5 Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 210
11.6 Explore Data . . . . . . . . . . . . . . . . . . . . . . . . . . . 212
11.7 Kaplan–Meier Survival Estimates . . . . . . . . . . . . . . . . . 215
11.8 Plot the Survival Probability . . . . . . . . . . . . . . . . . . . 217
11.9 Comparing Kaplan–Meier Estimates across Groups . . . . . . . . 219
11.9.1 Log-rank test . . . . . . . . . . . . . . . . . . . . . . . 219
11.9.2 Peto-peto test . . . . . . . . . . . . . . . . . . . . . . . 220
11.10 Semi-Parametric Models in Survival Analysis . . . . . . . . . . . 221
11.10.1 Cox proportional hazards regression . . . . . . . . . . . 222
11.10.2 Advantages of the Cox proportional hazards regression . . 223
11.11 Estimation from Cox Proportional Hazards Regression . . . . . . 224
11.11.1 Simple Cox PH regression . . . . . . . . . . . . . . . . . 224
11.11.2 Multiple Cox PH regression . . . . . . . . . . . . . . . . 227
11.12 Adding Interaction in the Model . . . . . . . . . . . . . . . . . 230
11.13 The Proportional Hazard Assumption . . . . . . . . . . . . . . . 232
11.13.1 Risk constant over time . . . . . . . . . . . . . . . . . . 232
11.13.2 Test for PH assumption . . . . . . . . . . . . . . . . . . 232
11.13.3 Plots to assess PH assumption . . . . . . . . . . . . . . . 233
11.14 Model Checking . . . . . . . . . . . . . . . . . . . . . . . . . 236
11.14.1 Prediction from Cox PH model . . . . . . . . . . . . . . 236
Contents xiii

11.14.2 Residuals from Cox PH model . . . . . . . . . . . . . . . 238


11.14.3 Influential observations . . . . . . . . . . . . . . . . . . 239
11.15 Plot the Adjusted Survival . . . . . . . . . . . . . . . . . . . . . 240
11.16 Presentation and Interpretation . . . . . . . . . . . . . . . . . 240
11.17 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 241

12 Parametric Survival Analysis 243


12.1 Objectives . . . . . . . . . . . . . . . . . . . . . . . . . . . . 243
12.2 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . 243
12.2.1 Advantages of parametric survival analysis models . . . . 244
12.3 Parametric Survival Analysis Model . . . . . . . . . . . . . . . . 244
12.3.1 Proportional hazard parametric models . . . . . . . . . . 245
12.3.2 Accelerated failure time model (AFT) models . . . . . . . . 245
12.4 Analysis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 246
12.4.1 Dataset . . . . . . . . . . . . . . . . . . . . . . . . . . 247
12.4.2 Set the environment . . . . . . . . . . . . . . . . . . . . 247
12.4.3 Read dataset . . . . . . . . . . . . . . . . . . . . . . . 248
12.4.4 Data wrangling . . . . . . . . . . . . . . . . . . . . . . 248
12.4.5 Exploratory data analysis (EDA) . . . . . . . . . . . . . . 249
12.4.6 Exponential survival model . . . . . . . . . . . . . . . . 250
12.4.7 Weibull (accelerated failure time) . . . . . . . . . . . . . 251
12.4.8 Weibull (proportional hazard) . . . . . . . . . . . . . . . 253
12.4.9 Model adequacy for Weibull distribution . . . . . . . . . 255
12.5 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 256

13 Introduction to Missing Data Analysis 257


13.1 Objectives . . . . . . . . . . . . . . . . . . . . . . . . . . . . 257
13.2 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . 257
13.3 Types of Missing Data . . . . . . . . . . . . . . . . . . . . . . 257
13.4 Preliminaries . . . . . . . . . . . . . . . . . . . . . . . . . . . 259
13.4.1 Packages . . . . . . . . . . . . . . . . . . . . . . . . . 259
13.4.2 Dataset . . . . . . . . . . . . . . . . . . . . . . . . . . 260
13.5 Exploring Missing Data . . . . . . . . . . . . . . . . . . . . . . 261
13.6 Handling Missing Data . . . . . . . . . . . . . . . . . . . . . . 264
13.6.1 Listwise deletion . . . . . . . . . . . . . . . . . . . . . 265
13.6.2 Simple imputation . . . . . . . . . . . . . . . . . . . . 265
13.6.3 Single imputation . . . . . . . . . . . . . . . . . . . . . 268
13.6.4 Multiple imputation . . . . . . . . . . . . . . . . . . . . 274
13.7 Presentation . . . . . . . . . . . . . . . . . . . . . . . . . . . 280
13.8 Resources . . . . . . . . . . . . . . . . . . . . . . . . . . . . 280
13.9 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 281

14 Model Building and Variable Selection 283


14.1 Objectives . . . . . . . . . . . . . . . . . . . . . . . . . . . . 283
14.2 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . 283
xiv Contents

14.3 Model Building . . . . . . . . . . . . . . . . . . . . . . . . . . 284


14.4 Variable Selection for Prediction . . . . . . . . . . . . . . . . . 285
14.4.1 Backward elimination . . . . . . . . . . . . . . . . . . . 285
14.4.2 Forward selection . . . . . . . . . . . . . . . . . . . . . 286
14.4.3 Stepwise selection . . . . . . . . . . . . . . . . . . . . . 286
14.4.4 All possible subset selection . . . . . . . . . . . . . . . . 286
14.5 Stopping Rule and Selection Criteria in Automatic Variable Selection 287
14.6 Problems with Automatic Variable Selections . . . . . . . . . . . 287
14.7 Purposeful Variable Selection . . . . . . . . . . . . . . . . . . . 288
14.8 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 288

Bibliography 289

Index 291
Exploring the Variety of Random
Documents with Different Content
OFFERO ... BEGAN TO CROSS THE FLOOD
2. THE FIR TREE

Far away in the forest grew a little Fir Tree. Around him stood tall
pines and firs so large that the little Fir felt very discontented,
wishing so much to be like the other trees. “If I were tall like them,”
sighed the Fir, “I would spread my branches so far the birds would
build their nests in my boughs, and when the wind blew, I should
bow grandly like them.” So unhappy was the little tree that he took
no pleasure in the warm sunshine, the birds, or the bright clouds.
One day in winter when the snow was on the ground, a little rabbit
jumped right over the little tree’s head. Oh, that made him so angry!
Two years after, the wood-cutters came and cut down several of the
largest trees and carried them away. “Where do they take these
trees?” the Fir Tree said; and a stork replied: “As I was flying here
from Egypt I saw great masts on the ships. That is what large trees
become.” “Oh, how I wish I were tall enough to be a mast and sail
on the sea!” sighed the Fir Tree.
Christmastime came, and many young trees were cut down, some
that were even smaller than the Fir Tree, and men carried them
away in wagons. “Where do they take those trees?” the Fir Tree
asked; and the sparrows chirped: “We know! we know! We peeped
in at the windows in the town and saw little trees like those planted
in the middle of a warm room, and made beautiful with gilded
apples, gingerbread, toys, and a hundred lights.” “I wonder if
anything like that will ever happen to me?” cried the discontented Fir
Tree; “that would be better than crossing the sea. Oh, when will
Christmas come?” The wind and air and sun and birds tried to make
the Fir Tree happy, but he only grew more discontented with his lot.
One day, just before Christmas, the wood-cutter came again, and
this time the Fir Tree was the first to be cut down and carried off.
But he could not think of happiness now, for he was sad at leaving
his home in the forest. He knew that he would never again see his
dear old friends, the trees, the bushes, the birds, and the flowers.
That morning the Fir Tree was stuck upright in a tub that stood on a
rich carpet in a splendid parlor. Some ladies came in and began to
dress his boughs with very pretty things—sugar-plums, apples,
oranges, walnuts, dolls; red, blue, and white candles; and to the top
was fastened a glittering golden star that shone as brightly as any
star in the sky. The tree looked very beautiful. “Oh,” sighed the tree,
“I wish all the candles were lighted! Will the trees of the forest come
to see me? Will the sparrows peep in at the windows? I wonder if I
shall stay pretty like this always?” At last the candles were lighted;
the folding doors opened; happy children trooped into the room
shouting and dancing with joy at the sight of the wonderful
Christmas tree. Older people came too, to look at the sight and
enjoy the presents which were taken one after the other from the
tree, until all the candles were burned low and put out and only the
glittering star remained. The happy children danced about the room
with their pretty toys, and no one cared for the tree or looked at him
except the nurse, who peeped among his branches to see if an apple
or a fig had been forgotten. All night the tree stood in darkness. In
the morning the servants dragged the tree from the tub and placed
him upstairs in the dark attic, where he stayed all winter, hidden
away from sight and forgotten by every one. In the spring the tree
was carried down-stairs and taken out into the yard. “Now I shall
live again,” said the Fir Tree, and he spread out his branches. But
alas! his leaves were all withered and yellow, yet the star of gold still
hung in the top, glittering in the sunshine. A boy seeing the star ran
up and pulled it off the tree. “Look what was sticking to this ugly old
Christmas tree,” he cried, trampling on the branches until they
cracked under his feet. A few minutes later the gardeners boy came
up with an axe and chopped the tree into small pieces and threw
them into the fire. And just as he was dying, the Fir Tree saw the
little boy wearing the star on his breast and sighed, “The night I was
crowned with that beautiful golden star was the happiest night of my
life.” And he knew that night of happiness was the longed-for
Christmas Eve.—Adapted from Hans Christian Andersen.

3. THE CHRISTMAS GIFT


Once in the sunny land of France there was a little girl named
Piccola, who lived all alone with her mother. They were very poor,
and little Piccola had no dolls or toys, and she was often hungry and
cold. One day when her mother was ill, Piccola worked hard all day
trying to sell the stockings which she knit, while her own little bare
feet were blue with cold. As Christmas drew near she said to her
mother: “I wonder what Saint Nicholas will bring me this year? I
have no stocking to hang in the fireplace, but I shall put my wooden
shoe on the hearth for him. He will not forget me, I am sure.” “Do
not think of it this year, my dear child,” replied her mother; “we
should be glad if we have bread enough to eat.” But Piccola could
not believe she would be forgotten. On Christmas Eve she put her
little wooden shoe on the hearth before the fire and went to sleep to
dream of good Saint Nicholas. The poor mother looked at the shoe
and thought how disappointed the little girl would be to find it empty
in the morning, and sighed to think she had nothing to put in it.
When the morning dawned Piccola awoke and ran to her shoe, and
there in it lay something with bright eyes looking up at her. A little
swallow, cold and hungry, had flown into the chimney and down to
the room and had crept into the shoe for warmth. Piccola danced for
joy, and clasped the shivering swallow to her breast. “Look! Look!”
she said to her mother. “A Christmas gift, a gift from the good Saint
Nicholas!” and she danced again in her little bare feet. Then she fed
and warmed the little bird, and cared for it tenderly all winter long.
In the spring she opened the window for it to fly away, but it lived in
the woods near-by, and sang often at her door.—Adapted from
“Child Life in Many Lands,” Blaisdell.

4. THE GOLDEN COBWEBS

(A story to be told by the Christmas tree)


The night before Christmas the tree was all trimmed with pop-corn,
and silver nuts, and golden apples, and oranges, and walnuts, and
dolls, and bonbons, and a hundred colored candles. It was placed
safely out of sight in a locked room where the children could not see
it until the proper time. But ever so many other little house-folks had
seen it. Pussy saw it with her great gray eyes. The house-dog saw it
with his steady brown eyes. The yellow canary saw it with his wise
bright eyes. Even the little mice had a good peek at it. But there was
some one who had not seen the Christmas tree. It was the little gray
spider! The housemother had swept and dusted and scrubbed to
make everything clean for the Christ-Child’s birthday and every
spider had scampered away. At last the little gray spider went to the
Christ-Child, and said: “All the others see the Christmas tree, dear
Christ-Child, but we are cleaned up! We like to see beautiful things
too!” The Christ-Child was sorry for the little spider, and he said,
“You shall see it.” So on Christmas morning before any of the
children were awake, the spiders came creeping, creeping, creeping
down the attic stairs, along the hall, under the door, and into the
room where the Christmas tree was standing. Oh! it was beautiful to
their little eyes as they looked upon it as much as they liked. Then
father spider, mother spider, and all the spider family went creeping,
creeping, creeping up the tree and all over its branches, and in great
joy hurried back to their home in the attic. The Christ-Child looked
down to see if the tree was all ready for the children, and oh!—it
was all covered over with cobwebs! “How badly the housewife will
feel at seeing those cobwebs!” said the Christ-Child. “I will change
them into golden cobwebs for the beauty of the Christmas tree.” So
that is how the Christmas tree came to have golden cobwebs.—
Adapted from “How to Tell Stories to Children,” by Sara Cone Bryant.

5. THE LEGEND OF THE CHRISTMAS TREE

One cold, wintry night, two little children were sitting by the fire
when suddenly they heard a timid knock at the door. One of the
children ran quickly and opened it. Outside in the cold and darkness,
they saw a poor little boy, shivering, without shoes on his feet, and
dressed in thin, ragged clothing. “Please, may I come in and warm
myself?” he said. “Yes, indeed,” cried the children, “you shall have
our place by the fire. Come in!” The little stranger boy came in and
the kind children shared their supper with him and gave him their
bed, while they slept on the hard bench. In the night they were
awakened by strains of sweetest music, and, looking out of the
window, they saw a band of children in shining garments coming
near the house. They were playing on golden harps, and the air was
full of Christmas music. Then lo! the Stranger-child, no longer in
rags, but clad in silvery light, stood before them, and in his soft
voice said: “I was cold and you let me in. I was hungry and you fed
me. I was very tired and you gave me your nice soft bed. I am the
Christ-Child who comes to bring peace and happiness to all kind
children. As you have been good to me, may this tree every year
bring rich gifts to you.” He broke a branch from the fir tree that grew
near the door and planted it in the ground, and disappeared. But the
branch grew into the Tree of Love, and every year it bore golden
fruit for the kind children.—Adapted from Lucy Wheelock in Bailey-
Lewis, “For the Children’s Hour.”
VI
BIBLE STORIES FROM THE OLD TESTAMENT
(Adapted for Children, Six to Twelve Years.)

1. HOW THE WORLD WAS MADE

(Genesis 1, 2)

I nthe beginning, long, long ago, God created this wonderful world
and all things in it. At first there was no earth, no sun, no moon or
stars, no grass or trees, no seas or sky. This great round ball, on
which we live, was nothing but a great cloud of mist without shape
or size. Everywhere there was great darkness. God was living in his
home in heaven, and he said, “Let there be light.” So light was the
first wonderful thing God made. Then God separated the sky mists
from the earth mists. He made the waters roll back into seas; and
the mountains, with great lakes between, appeared. When the sun
and moon and stars shone out more brightly, driving the mists and
water away from the dry land, God made grass and trees and
flowers to spring up in great beauty and abundance; and each tree
and flower had little, tiny seeds to send up little shoots to make
others. Then great swarms of living things appeared—strange fishes
and sea-monsters to swim in the waters, reptiles and creeping things
to creep on the land, birds to fly through the air, and all kinds of
four-footed beasts to roam through the forests. Still, there was no
man nor woman, nor any little child anywhere to enjoy what God
had made. So God created a man and called his name Adam. God
placed him in a large garden called Eden, filled with beautiful and
useful things—rivers of water to water it, gold and precious stones,
trees good for food, animals, birds, and fishes. Adam gave names to
all the animals. But among them all there was not one to talk with
him. So God made a beautiful companion for Adam and called her
name Eve. This first man and woman lived together very happily in
this beautiful Garden of Eden, caring for the flowers and fruit,
watching the animals, loving each other, and talking with God, their
Creator and Friend.

2. HOW A HAPPY HOME WAS LOST

(Genesis 3)
Adam and Eve were very happy in their beautiful garden-home in
Eden. In the cool of the day, when the sun went down, and the
garden was quiet, they knew that God was very, very near them,
walking and talking with them. All the animals and plants, all the
beautiful trees were for their use. But there was one tree with fruit
that God, to teach them to obey, told them not to eat. For a long
time they thought of nothing else but doing exactly what God told
them. But one day Eve stopped in front of the tree and looked at the
fruit. How good it looked! She wondered how it tasted. Then she
turned to go away, for she knew that God had said that whoever
tasted it would die. Just then she heard a voice. She looked, and the
voice came from a bright, shining snake, coiled close in front of the
tree. The snake said, “Did God say you shall not eat of any tree of
this garden?” Eve said, “God said we shall not eat of this tree, nor
touch it, lest we die.” “You will be like God if you eat it; you will
know good and evil.” She listened to this voice tempting her to do
what was wrong. Then she looked at the tree again. It looked so
good to eat and so pretty, and as if it would make one know a great
deal, that she picked some of the fruit and ate it. Then she ran and
gave some to Adam, and he ate it too. That evening, when the sun
was going down, making long shadows upon the grass, and a cool
breeze was rustling the leaves, and the garden was all lonely and
still, Adam heard the sound of God in the garden. Instead of gladly
running to meet their heavenly Father and Friend, as they had
always done before when he came to talk with them, they were
afraid, and ran and hid themselves among the trees. God called to
Adam, “Where art thou?” Guilty and ashamed, Adam said, “I heard
thy voice, and I was afraid.” God said, “Hast thou eaten of the tree
of which I commanded thee not to eat?” Adam said, “Eve gave it to
me and I ate.” Eve said, “The snake tempted me, and I ate.” God
told the snake he must crawl always flat on the ground, and every
animal and man would hate him more than any other creature. He
told Adam and Eve, because they had disobeyed him, they must be
driven out of the beautiful garden and must dig and work hard in
getting their food in desert lands among thistles and thorns, stones
and timber, and at last, he said, they must die. But God still loved
them, and gave them a beautiful promise of a loving Saviour who
would be so obedient and pure and strong that he would prepare for
them a beautiful city in the place of their garden-home, which they
had lost through disobedience.

3. THE FIRST TWO BROTHERS

(Genesis 4)
The first two brothers in the world were Cain and Abel. They were
born after their parents were driven out of their beautiful garden-
home in Eden. When these boys grew up, Cain, the elder, became a
farmer, and Abel became a shepherd. Their parents brought them up
always to ask God to forgive them when they did wrong, and to
bring offerings to him of what they had. One day when they came
with their gifts, Abel, with a loving heart, carried a lamb, the best of
his flock, but Cain brought some fruit in a careless way. God was
well pleased with Abel’s gift, because of the love that came with it;
but not with Cain’s, because Cain kept hatred to his brother in his
heart. Cain was angry and his face became dark and scowling. God
said: “Why are you angry and scowling? If you do well, will you not
be happy? If you do not well, hatred in your heart will crouch, like a
lion, ready to spring at you.”
But Cain paid no attention to God’s loving word. One day he said to
Abel, “Come into the field with me.” When they were there alone,
the crouching lion of hatred in Cain’s heart sprang up, and Cain lifted
up his hand and slew his brother. Then Cain heard God’s voice
saying, “Where is thy brother?” He answered untruthfully, “I know
not; am I my brother’s keeper?” Then as Cain had done this wicked
deed, God sent him from his home and parents to become a
wanderer on the earth, working even harder than his father and his
mother did. Cain’s suffering was just what he had brought upon
himself, yet he said, “My punishment is greater than I can bear.” He
was afraid wherever he went men would seek to kill him, for he
knew he deserved to be killed. But God gave him a mark by which
he could know that God was still watching over him and would not
let any one kill him. So Cain went away and built a city and lived
unhappily the rest of his life, away from his father and mother,
because he had allowed hatred instead of love to live in his heart,
and because he had not tried to please his loving Father in heaven.

4. THE FLOOD AND THE RAINBOW

(Genesis 6-8)
Once when God looked down on the people of the earth, he saw
that there was only one good man to be found anywhere. All the
rest were disobedient and very wicked. So God planned to save all
who would be obedient to him, but to destroy all the disobedient, in
order that such great wickedness should not increase over all the
earth. God told Noah, the one just and good man, his plan. He told
him to build a large ark, half boat and half house. It was to be five
hundred feet long, fifty feet high, and eighty-three feet wide—about
the size of a big ocean steamer to-day. There were to be three
stories, many rooms, and a window on the top. The one door was to
be on the side. This great houseboat was not to be for travel, but
only to float on the water. In the ark Noah, his wife and sons, and
his sons’ wives, and all others who would obey God, were to be
saved. For one hundred long years Noah and his sons worked away
building this strange ship—hammering, sawing, planing, and laying
great beams hundreds of feet long. The people laughed at Noah and
mocked him. It was very hard for Noah to be mocked, but he kept
right on with his work, telling them of God and his holiness and how
their wickedness was grieving God. But they would not listen, nor
change their ways, nor believe any flood would come. At last the
great ark was finished. Then Noah gathered together two of every
kind of birds and animals, and they marched or flew into the ark,
and behind them Noah and his family went in, with food for all to
last for many months. And God shut the door. So they were safe
because they had obeyed God.
Then the rain began to fall. Thunder crashed and echoed from the
mountains and the wind dashed the rain against the ark. Torrents of
rain came down, until soon the ark began to float. Higher and higher
it rose, rocking and tossing, up above the treetops, above the hills,
above the mountains. The flood had come, and the wicked people
were all drowned. But Noah and his family were safe inside the ark.
After forty days the rain stopped, but the water flooded in from the
sea. For one hundred and fifty days the waters rose, and then began
to go down. But the ark rested on one of the high mountains. Noah
opened the window and sent forth a raven, and then a dove. The
raven flew away, resting on things floating in the water. The dove
came back several times, once bearing an olive-branch in her beak.
At last she did not return, by which Noah knew the dove had found
land on which to rest, and that the water was gone. Then Noah and
all in the ark went out, after being in it more than a year. The first
thing Noah did was to thank God for saving him and his family. Then
Noah looked up in the clear, blue sky and there was a wonderful
rainbow, with every color in it, arching the heavens. This was God’s
sign and promise that he would never again destroy the world with
water. So every time they saw a rainbow after that, they
remembered that God was looking at it too, remembering this
promise of his: “During all the days of the earth, sowing and
reaping, and cold and heat, and summer and winter, and day and
night, shall not cease.”
My heart leaps up when I behold
A rainbow in the sky;
So was it when my life began;
So is it now I am a man;
So be it when I shall grow old,
Or let me die!
The child is father to the man;
And I could wish my days to be
Bound each to each by natural piety.

5· THE GENEROUS UNCLE AND THE SELFISH NEPHEW

(Genesis 12-19)
Long, long after the flood, there lived a good man whose name was
Abram, “the friend of God.” He was the first Hebrew. At first he lived
in a large city on the river Euphrates. It was a beautiful city with fine
buildings, gardens, fountains, statuary, and other things for comfort
and pleasure. Abram and his people were rich. They had everything
to make them happy, excepting one thing. Abram saw that in all that
great city, in all that country, none worshiped God but himself. There
were many temples where the people worshiped the sun, moon,
stars, and many false gods. There were beautiful temples built, and
beautiful music sung to the Sun-god, but no thanks were given to
the great Creator of the sun and moon and man. A good deal of
their worship was very wicked and cruel, and often boys and girls
were burned to please the idols. Abram saw all this was false and
wicked. One day God told him to leave that land and take a long
journey to another land that God would show him. At last Abram
reached a land so rich in vines, fruit trees, and pastures for flocks
and herds, that it was called “the land flowing with milk and honey.”
Here Abram and Lot, his brother’s son, lived in tents. Both were very
rich in cattle, goats, sheep, servants, and silver and gold. But when
the servants of Lot and Abram kept quarreling over which should
have the best pasture for feeding their flocks, Abram said to Lot:
“Let there be no quarrel between thee and me, and between our
servants, for we are brethren. Choose the land you wish, and I will
take what is left.” Abram was older than Lot, and had always been
kind and generous, like a father, to him. Lot should have given his
uncle the first choice. Instead of that, Lot greedily chose the well-
watered plain-lands near the river Jordan, leaving to his uncle the
hilly land. Abram generously let him keep them. Lot moved close to
the wicked city of Sodom. Soon after, in a battle, Lot and his family
and his servants were taken prisoners. Lot had not treated his uncle
well, but that made no difference to Abram. He was a true friend,
loving Lot even when he did not do right. So he rescued Lot and
saved all the property the kings had stolen. Lot went back to Sodom,
making his home this time inside the city, among its wicked people,
and he grew more forgetful of God.
One day, in Sodom and Gomorrah, the cities of the plain, a great fire
broke out which destroyed everything Lot had. Only for Abram’s
prayer to God, Lot would have been burned up too. But for Abram’s
sake, two angels came and led Lot and his wife and two daughters
out of the city, telling them not to look back nor stay in all the plain,
but flee to the mountains. Lot’s wife looked longingly back at the
wicked cities, and was changed into a pillar of salt in the very plain
upon which she, with Lot, had so much set her heart. Lot and his
two daughters were saved only by fleeing to the mountain land that
Lot had despised and Abram had taken. So, after all, the selfish
nephew did not choose so well as the unselfish uncle, “the friend of
God.”
Yes, Faith, Life, Song, most meetly named him “Friend”;
All men’s he was and is, till time shall end.
And in the Christ-path he so closely trod
That all men saw he was “the Friend of God.”

6. THE OBLIGING GIRL AT THE WELL

(Genesis 24)
“Laughter” is a queer name for a boy. But “Laughter” is the name
Abraham gave his son. That is what Isaac means. When Isaac grew
up Abraham did not like the idea of his son marrying any of the
young women of that land because they all worshiped idols; so he
called his head servant and told him to go far away to the country
where Abraham’s own people lived, and there find a young woman
who would be the right sort of wife for Isaac. It was a long, long
journey across the desert. Abraham gave the servant ten camels,
and servants, and tents, with gold and silver, and precious stones
and rich robes, to give as presents to the young woman and her
family. After many days of travel the servant came to a city where
some of Abraham’s people were still living. Outside the city was a
well with a trough for the camels to drink from. He knew every
evening young girls and women came with their pitchers for drinking
water to this well. He decided when they came he would ask for a
drink, and whoever gave him a drink and also offered to give the
camels a drink by filling the watering-trough, would prove the wife
for Isaac. He also prayed God to guide him. While he was praying
there came to the well a beautiful young girl carrying a pitcher on
her shoulder. When she had filled her pitcher the servant said, “Let
me drink, please.” She said, “Drink, my lord,” and quickly let down
her pitcher upon her hand and gave him a drink. Then seeing how
tired the camels looked, her kind heart made her say, “I will get
water for your camels too.” Camels drink a great deal of water, and
there were ten of them, but this obliging girl did not stop filling the
large watering-trough until every thirsty beast had drunk enough.
Quietly the servant watched her, and when he saw how friendly she
was he gave her a splendid gold earring and two beautiful bracelets
of gold and asked her name and whether there was room in her
father’s house for him to stay over night. She told him her name was
Rebecca—a relative of Abraham’s family—and said there was plenty
of room for them to spend the night. Then the servant thanked God,
for he knew this kind, obliging girl was just the one whom God
wanted to become Isaac’s wife. When they came to the house, the
servant told his story to all, and gave still more beautiful presents to
Rebecca and to her sister and brothers. Early the next morning the
old servant wanted to start back at once, because God had
prospered his journey. They called Rebecca and said to her, “Wilt
thou go with this man?” And she said, “I will go.” So Rebecca’s queer
bridal party, herself and her old nurse, Deborah, and several maids,
mounted on camels and escorted by Abraham’s servants, began the
long march to Isaac’s home in Canaan where she and Isaac were
married. They loved each other dearly. And Abraham was glad that
“Laughter” had found so good and true a wife in the friendly girl at
the well.

7. THE LADDER THAT REACHED TO HEAVEN

(Genesis 28)
Isaac and Rebecca had two boys, Esau and Jacob. Esau became a
hunter, and Jacob a shepherd. One day Esau came home from
hunting very hungry. He asked Jacob to give him some of the red
broth that he had just cooked. Jacob knew that Esau cared nothing
for his birthright (that is, all that he would receive as the eldest son).
But Jacob wanted that more than anything else in the world. So
Jacob said, “Will you give me your birthright if I do?” Esau said,
“Yes, I am starving; give me the broth for the blessing.” Jacob could
not believe Esau meant it; but he did mean it, and so sold his
birthright for something to eat. Not long after, Jacob received the
birthright blessing from his father, Isaac. Then Esau was sorry and
angry, and hated his brother, and planned to kill him. Rebecca told
Jacob what Esau was planning to do, and sent him to her brother’s
home to save Jacob’s life.
So Jacob had to leave his father and mother and home and start
alone on a long journey with nothing but a long cloak to wrap about
him at night. When the sun went down, as he was thinking of the
great wrong he had done his brother, tired and sad at heart, he lay
down to sleep on a stony hillside, placing one of the stones under
his head for a pillow. At last he fell asleep, and in his dream he saw
a ladder reaching from earth to heaven. He saw beautiful shining
angels coming down the ladder and going back. At the top he saw
God looking down on him, saying, “I am the Lord, the God of
Abraham and thy father Isaac.” God promised if he would do what
was right, that he would forgive all his wrong—be with him in all his
journey and give him the wonderful promises made to Abraham and
Isaac.
Early in the morning, when Jacob awoke, he knelt beside that stone,
promising God that he would be a better man. He lived to be an
aged man—one hundred and forty-seven years old—but he never
forgot that place which he called “The House of God,” from which he
saw the ladder that reached to heaven, showing him that God was
near him.
From this story the beautiful lines of the hymn, which have been
such a comfort to many upon battlefields and in the hour of death,
were written:
Though like a wanderer,
The sun gone down,
Darkness be over me,
My rest a stone,
Yet, in my dreams I’d be,
Nearer, my God, to thee,
Nearer to thee.

8. THE SLAVE-BOY WHO BECAME A PRINCE

(Genesis 37 to 47)
Jacob had twelve sons, and Joseph was next to the youngest. He
was the best loved of all, and his father showed how much he loved
him by giving him a coat of many colors. This made his older
brothers jealous and angry. When Joseph was sixteen years old he
dreamed that he was binding sheaves of grain in a field with his
eleven brothers and his father and mother, and all the other sheaves
bowed down to his sheaf. Another dream he had was that the sun
and moon and eleven stars bowed down to him. When Joseph
awoke he told these queer dreams to his brothers. No wonder they
called him “the dreamer” and teasingly said, “Shall we all, indeed,
come to bow down to you?” Soon after this his nine big brothers
caught this boy out in a field and put him down into a deep pit, and
then sold him to camel-drivers as a slave for twenty pieces of silver
(about one hundred and twenty dollars). Then they killed one of
their own goats, dipped Joseph’s coat of many colors, which they
had taken off him, into the blood, and taking it home, wickedly
made their father think a wild beast had eaten Joseph. Jacob
mourned for him as dead, and the brothers thought the dreamer
would never tell any more of his dreams.
The camel-drivers sold Joseph as a slave in Egypt to a rich man who
promoted him to be the chief ruler of his great house. It was a fine
place for him. But one day some one told a very wicked lie about
him, and he was cast into prison. But Joseph was so cheerful and
kind and useful, even in prison, that he was soon placed over all the
prisoners. When the king heard that Joseph had power to tell people
the meaning of their dreams, he sent for him to tell the meaning of
two dreams that troubled him. Joseph told the king his dreams. So
Joseph was removed from prison to the king’s palace, and was
dressed in fine clothes, with a gold chain around his neck and a gold
ring on his finger, and made ruler over all the land, next to the king.
Soon a great famine arose (just as Joseph had told the king) in all
lands except Egypt, because Joseph had filled big barns with corn.
Joseph’s ten brothers came from Canaan to Egypt to buy food to
keep their families from starving. They were taken into the presence
of the great ruler who sold the corn, and they bowed down to the
earth before him. So the dreamer’s dream came true, though they
did not know it then. Joseph knew them, and treated them kindly
without letting them know he was their brother. He longed to see his
youngest brother, Benjamin, and told the older brothers to bring him
down with them when they came again, or they could have no more
corn. When they brought him, and when Joseph looked upon
Benjamin’s face, this great Prince of Egypt burst into tears and said,
“I am Joseph, your brother, whom ye sold into Egypt, but whom God
sent before you to preserve life.” Then they were afraid, but Joseph
lovingly put his arms about their necks and kissed them and cried
with them until they knew that he freely forgave them. So they went
home quickly and brought their old father, Jacob, the good news,
“Joseph is yet alive, and he is ruler over all the land of Egypt!” Jacob
could scarcely believe them. But when they told him how he had
forgiven their wickedness, he said, “I will go and see him before I
die.” So all together they went to Egypt and lived in a beautiful
house which Joseph gave them. Then he took good care of them all,
and lived near his dear old father until the old man died, happily and
peacefully, because he was with his beloved Joseph, whom he had
lost as a slave and had found again as a prince.

9. THE BABY BROTHER IN A BASKET-BOAT

(Exodus 2)
Long, long ago, a little boy was born in a Hebrew home, at a time
when a cruel king of Egypt ordered all Hebrew boys that were born,
to be thrown to the crocodiles in the great river Nile. But this little
babe was so beautiful that his mother hid him in the house and
prayed God to keep him safe. She hid him carefully for three
months. Then, being afraid some one might hear him, she went to
the river and gathered some long, strong grasses that grew there
and braided them together, making a small basket and shaping it like
a boat. To make it warm and dry inside, and to keep it from sinking
when placed in the water, she painted it with black paint inside and
out. Early one morning, when all was ready, the mother took her
baby boy quietly sleeping in the basket-boat, and went down to the
river Nile, the little baby’s sister, Miriam, following closely behind her.
The mother hid the basket among the tall grasses near the shore,
and again prayed God to keep her baby safe. Miriam was left hiding
in the tall grass near-by to see what would happen to her little
brother in his new bed. Very soon the princess, the daughter of the
cruel king of Egypt, with her maids, came down to the river to
bathe. Quickly she spied the basket-boat and cried, “What is that
floating on the water among the tall grasses? Bring it to me.” One of
her maids ran and picked up the basket and brought it to the
princess. When she opened it, there was the most beautiful baby
boy she had ever seen! The child was wide awake, and seeing the
strange face, began to cry. “It is one of the Hebrew babies that my
father ordered drowned!” she said. “But I have found him, and I will
keep him as my own little baby boy. I will call his name ‘Moses.’”
Miriam was watching from her hiding-place in the tall grasses. She
ran out and said, “Shall I bring a nurse for the baby?” “Yes,” said the
princess. Miriam ran home as fast as she could, and whom do you
suppose she brought? The baby’s own mother! And the princess told
her to take him home and nurse him and care for him for her, for
she loved him as her very own, and the king would not harm him.
So the prayer that Moses’ mother made to God to take care of her
little baby boy in the basket-boat was answered. And Moses grew up
to be a great and good man.

10. WHY BOYS TAKE OFF THEIR HATS IN CHURCH

(Exodus 3)
When the boy Moses was old enough to leave his mother he went to
live with his new mother in the king’s palace.
Moses was a good boy. He studied his lessons so well in school that
he grew up to be one of the wisest and best young men in all the
land. But Moses never forgot his own Hebrew people. He was not
careless of the cruel way they were treated as slaves by the king’s
officers. He tried to improve their sad condition in his own hasty
way, but he soon saw that neither his own people nor their masters
wanted a princess’s son to interfere. They were both ready to kill
him for trying to help. So Moses had to flee for his life into the
mountains where he became a shepherd. One day as he was leading
his sheep up the mountainside, he saw a thorn-bush all aflame; and
it kept on burning, but was not burned up. Moses wondered to see
so strange a sight. Leaving his sheep he went near. Suddenly a Voice
called out of the midst of the fire-bush, “Moses! Moses!” Moses
answered, “Here am I.” The Voice said, “Take off thy shoes from off
thy feet, for the place whereon thou standest is holy ground,” It was
God, in the form of an angel, speaking to him. Moses at once took
off his shoes and bowed reverently in the presence of God. Then
God told him a better way by which he could help his downtrodden
people and set them free from their cruel masters who were beating
them and making their life so hard. He told Moses he wanted him to
lead his people out of their bondage. At first Moses was afraid he
was not able to do what God wanted him to do, but God said,
“Certainly, Moses, I will be with thee.” Moses obeyed the Voice that
spoke that day to him out of the fire-bush, and he became one of
the greatest of leaders and lawgivers that this world ever saw. Men
and boys take off their hats in church to-day for the same reason
that Moses removed his shoes before the fire-bush—to show
reverence in the presence of God and respect for his wonderful way
of speaking to men.

II. THE BOY WHO LIVED IN A CHURCH

(1 Samuel 2, 3)
Once there was a little boy, about seven years old, who was taken
by his mother to a beautiful church and left there to be educated by
the minister, who lived in a room at the side of the church. The little
boy’s mother had promised God that if he would give her a little boy
she would give him back to him, and that all the days of his life her
boy should serve him. So as soon as he was old enough to leave her
she remembered her promise. A little room was fitted up for the little
fellow next to the minister’s room. Little Samuel learned to trim the
lamps, to open and close the church doors, and to be useful in many
little ways in helping the minister. Once a year his mother came to
see him, bringing for him a beautiful little, new, white coat, which
she had made for him. It was the same kind of white coat the
minister wore. One night as the little boy was lying asleep in his
room, suddenly a beautiful Voice rang through the chamber, calling,
“Samuel! Samuel!” Samuel thought it was the minister calling him.
He ran to the minister’s room, saying, “Here am I!” “I called not,”
said the minister; “lie down again.” So the boy went back to bed.
Then again the Voice called, “Samuel!” Again he ran to the minister
who said, “I called not; lie down again.” When all was quiet, the
third time the Voice called, “Samuel!” and again the boy sprang up
and ran quickly to the minister’s room. Then the minister knew God
was calling him. “Go lie down,” he said, “and if you hear the Voice
again, it is God calling you; say, ‘Speak, Lord, for thy servant
heareth.’” As soon as Samuel lay down again, God called, “Samuel!
Samuel!” and little Samuel kneeling beside his bed said, “Speak,
Lord, for thy servant heareth.” Then God told him what he wished
him to do for him when he grew older. So the little boy who was
obedient to God’s voice grew up to be a great and good man, living
always for the good of his people.

12. THE DAUGHTER WHO HONORED HER MOTHER

(Book of Ruth)
Far away in the strange land of Moab a poor widow started to return
to her own home in the land of Israel. Ruth and Orpah, her two
daughters-in-law, the wives of her sons who had just died, wished to
go with her, for they could not think of the poor, old, sad mother
returning all by herself on that long journey. But after they had gone
a little way, the old mother kissed them and said, “Go back to your
home and native land!” So Orpah kissed her good-bye and returned,
but Ruth clung to her mother-in-law and said: “Entreat me not to
leave thee and return from following after thee; for whither thou
goest I will go; and where thou lodgest I will lodge; thy people shall
be my people, and thy God my God; where thou diest will I die, and
there will I be buried. Nothing but death shall part thee and me.”
Ruth knew that where Naomi was going she would be poor, and that
they would have to work hard, but she loved this old mother too
much to leave her. Soon they saw the hills and then the houses of
Bethlehem, Naomi’s home. They settled down in that little town, but
were so poor they did not know how to get even food enough to
eat. The time of year had come when the farmers were beginning to
cut the barley—the harvest-time. It was the custom in that land to
allow poor people to go into the fields and gather up the loose ears
of barley that were left by the reapers; and Ruth went to glean a
little food for herself and her mother. She happened to go into the
field of a rich man named Boaz. By and by when Boaz came to see
how the reapers were getting on, he saw Ruth gleaning, and asked
his reapers who she was. They told him that she was Naomi’s
daughter-in-law, just come from Moab. Then Boaz called her to him
and told her that she was welcome to glean in his fields all through
the harvest. He said: “I have heard all about your goodness to
Naomi. May you be fully rewarded by Jehovah, the God of Israel,
under whose wings you have come to take refuge.” At dinnertime
Boaz told her to sit down with the reapers, who gave her food and
drink. She ate all she wished, and still she had some left, which in
the evening she took home with her, with the barley she had
gleaned, to Naomi. At the end of the barley harvest, this great and
good rich man, Boaz, fell in love with Ruth, and she became his wife.
The old mother, Naomi, went to live with them in their large and
beautiful house, and she never was in want again. When a little son
came to them, Ruth called his name Obed, and when he grew to be
an old man, he was the grandfather of King David. So Ruth, the
gleaner, who was kind and loyal to her mother-in-law, became the
great-grandmother of the greatest King of Israel.

You might also like