Copyright....6
Table of Contents....7
Preface....13
Who This Book Is For....14
Who This Book Is Not For....15
R and Python Code....16
Code Environments....16
Code Conventions....17
Functional-Style Programming 101....18
Using Code Examples....18
Navigating This Book....19
Conventions Used in This Book....20
O’Reilly Online Learning....21
How to Contact Us....21
Acknowledgments....22
Part I. Understanding Behaviors....23
Chapter 1. The Causal-Behavioral Framework for Data Analysis....25
Why We Need Causal Analytics to Explain Human Behavior....26
The Different Types of Analytics....26
Human Beings Are Complicated....27
Confound It! The Hidden Dangers of Letting Regression Sort It Out....30
Data....31
Why Correlation Is Not Causation: A Confounder in Action....31
Too Many Variables Can Spoil the Broth....33
Conclusion....39
Chapter 2. Understanding Behavioral Data....41
A Basic Model of Human Behavior....42
Personal Characteristics....43
Cognition and Emotions....45
Intentions....46
Actions....47
Business Behaviors....48
How to Connect Behaviors and Data....50
Develop a Behavioral Integrity Mindset....50
Distrust and Verify....51
Identify the Category....52
Refine Behavioral Variables....54
Understand the Context....55
Conclusion....57
Part II. Causal Diagrams and Deconfounding....59
Chapter 3. Introduction to Causal Diagrams....61
Causal Diagrams and the Causal-Behavioral Framework....62
Causal Diagrams Represent Behaviors....63
Causal Diagrams Represent Data....64
Fundamental Structures of Causal Diagrams....68
Chains....68
Forks....72
Colliders....74
Common Transformations of Causal Diagrams....75
Slicing/Disaggregating Variables....76
Aggregating Variables....77
What About Cycles?....79
Paths....82
Conclusion....83
Chapter 4. Building Causal Diagrams from Scratch....85
Business Problem and Data Setup....86
Data and Packages....86
Understanding the Relationship of Interest....87
Identify Candidate Variables to Include....89
Actions....91
Intentions....92
Cognition and Emotions....93
Personal Characteristics....94
Business Behaviors....97
Time Trends....97
Validate Observable Variables to Include Based on Data....99
Relationships Between Numeric Variables....100
Relationships Between Categorical Variables....103
Relationships Between Numeric and Categorical Variables....106
Expand Causal Diagram Iteratively....108
Identify Proxies for Unobserved Variables....108
Identify Further Causes....109
Iterate....110
Simplify Causal Diagram....110
Conclusion....112
Chapter 5. Using Causal Diagrams to Deconfound Data Analyses....113
Business Problem: Ice Cream and Bottled Water Sales....114
The Disjunctive Cause Criterion....116
Definition....116
First Block....117
Second Block....119
The Backdoor Criterion....119
Definitions....120
First Block....122
Second Block....123
Conclusion....125
Part III. Robust Data Analysis....127
Chapter 6. Handling Missing Data....129
Data and Packages....131
Visualizing Missing Data....132
Amount of Missing Data....135
Correlation of Missingness....137
Diagnosing Missing Data....143
Causes of Missingness: Rubin’s Classification....146
Diagnosing MCAR Variables....148
Diagnosing MAR Variables....150
Diagnosing MNAR Variables....152
Missingness as a Spectrum....154
Handling Missing Data....158
Introduction to Multiple Imputation (MI)....159
Default Imputation Method: Predictive Mean Matching....162
From PMM to Normal Imputation (R Only)....163
Adding Auxiliary Variables....165
Scaling Up the Number of Imputed Data Sets....167
Conclusion....168
Chapter 7. Measuring Uncertainty with the Bootstrap....169
Intro to the Bootstrap: “Polling” Oneself Up....170
Packages....170
The Business Problem: Small Data with an Outlier....170
Bootstrap Confidence Interval for the Sample Mean....172
Bootstrap Confidence Intervals for Ad Hoc Statistics....177
The Bootstrap for Regression Analysis....179
When to Use the Bootstrap....182
Conditions for the Traditional Central Estimate to Be Sufficient....183
Conditions for the Traditional CI to Be Sufficient....183
Determining the Number of Bootstrap Samples....186
Optimizing the Bootstrap in R and Python....187
R: The boot Package....187
Python Optimization....190
Conclusion....191
Part IV. Designing and Analyzing Experiments....193
Chapter 8. Experimental Design: The Basics....195
Planning the Experiment: Theory of Change....196
Business Goal and Target Metric....197
Intervention....199
Behavioral Logic....201
Data and Packages....203
Determining Random Assignment and Sample Size/Power....204
Random Assignment....204
Sample Size and Power Analysis....207
Analyzing and Interpreting Experimental Results....221
Conclusion....224
Chapter 9. Stratified Randomization....225
Planning the Experiment....227
Business Goal and Target Metric....227
Definition of the Intervention....229
Behavioral Logic....230
Data and Packages....230
Determining Random Assignment and Sample Size/Power....231
Random Assignment....231
Power Analysis with Bootstrap Simulations....239
Analyzing and Interpreting Experimental Results....246
Intention-to-Treat Estimate for Encouragement Intervention....247
Complier Average Causal Estimate for Mandatory Intervention....248
Conclusion....254
Chapter 10. Cluster Randomization and Hierarchical Modeling....255
Planning the Experiment....256
Business Goal and Target Metric....256
Definition of the Intervention....256
Behavioral Logic....258
Data and Packages....258
Introduction to Hierarchical Modeling....259
R Code....260
Python Code....262
Determining Random Assignment and Sample Size/Power....264
Random Assignment....264
Power Analysis....266
Analyzing the Experiment....274
Conclusion....274
Part V. Advanced Tools in Behavioral Data Analysis....277
Chapter 11. Introduction to Moderation....279
Data and Packages....280
Behavioral Varieties of Moderation....280
Segmentation....281
Interactions....287
Nonlinearities....288
How to Apply Moderation....291
When to Look for Moderation?....292
Multiple Moderators....303
Validating Moderation with Bootstrap....309
Interpreting Individual Coefficients....311
Conclusion....317
Chapter 12. Mediation and Instrumental Variables....319
Mediation....320
Understanding Causal Mechanisms....320
Causal Biases....321
Identifying Mediation....323
Measuring Mediation....324
Instrumental Variables....329
Data....329
Packages....330
Understanding and Applying IVs....330
Measurement....333
Applying IVs: Frequently Asked Questions....336
Conclusion....337
Bibliography....339
Index....343
About the Author....359
Colophon....359
Harness the full power of the behavioral data in your company by learning tools specifically designed for behavioral data analysis. Common data science algorithms and predictive analytics tools treat customer behavioral data, such as clicks on a website or purchases in a supermarket, the same as any other data. Instead, this practical guide introduces powerful methods specifically tailored for behavioral data analysis.
Advanced experimental design helps you get the most out of your A/B tests, while causal diagrams allow you to tease out the causes of behaviors even when you can't run experiments. Written in an accessible style for data scientists, business analysts, and behavioral scientists, this practical book provides complete examples and exercises in R and Python to help you gain more insight from your data--immediately.