Quantitative Social Science Quantitative Social Science An Introduction KOSUKE IMAI PRINCETON UNIVERSITY PRESS Princeton and Oxford Epigraphonpage189fromTukey,JohnW.,1977,Exploratorydataanalysis. Reading,Mass:Addison-WesleyPublishing,animprintofPearsonEducation,Inc. Copyright©2017byPrincetonUniversityPress PublishedbyPrincetonUniversityPress,41WilliamStreet, Princeton,NewJersey08540 IntheUnitedKingdom:PrincetonUniversityPress,6OxfordStreet, Woodstock,OxfordshireOX201TR press.princeton.edu AllRightsReserved ISBN978-0-691-16703-9 ISBN(pbk.)978-0-691-17546-1 LibraryofCongressControlNumber2016962298 BritishLibraryCataloging-in-PublicationDataisavailable ThisbookhasbeencomposedinMinionProandUniversfordisplay Printedonacid-freepaper∞ TypesetbyNovaTechsetPvtLtd,Bangalore,India PrintedintheUnitedStatesofAmerica 10 9 8 7 6 5 4 2 1 ToChristina,Keiji,andMisaki Contents ListofTables xiii ListofFigures xv Preface xvii 1 Introduction 1 1.1 OverviewoftheBook 3 1.2 HowtoUsethisBook 7 1.3 IntroductiontoR 10 1.3.1 ArithmeticOperations 10 1.3.2 Objects 12 1.3.3 Vectors 14 1.3.4 Functions 16 1.3.5 DataFiles 20 1.3.6 SavingObjects 23 1.3.7 Packages 24 1.3.8 ProgrammingandLearningTips 25 1.4 Summary 27 1.5 Exercises 28 1.5.1 BiasinSelf-ReportedTurnout 28 1.5.2 UnderstandingWorldPopulationDynamics 29 2 Causality 32 2.1 RacialDiscriminationintheLaborMarket 32 2.2 SubsettingtheDatainR 36 2.2.1 LogicalValuesandOperators 37 2.2.2 RelationalOperators 39 2.2.3 Subsetting 40 2.2.4 SimpleConditionalStatements 43 2.2.5 FactorVariables 44 2.3 CausalEffectsandtheCounterfactual 46 viii Contents 2.4 RandomizedControlledTrials 48 2.4.1 TheRoleofRandomization 49 2.4.2 SocialPressureandVoterTurnout 51 2.5 ObservationalStudies 54 2.5.1 MinimumWageandUnemployment 54 2.5.2 ConfoundingBias 57 2.5.3 Before-and-AfterandDifference-in-DifferencesDesigns 60 2.6 DescriptiveStatisticsforaSingleVariable 63 2.6.1 Quantiles 63 2.6.2 StandardDeviation 66 2.7 Summary 68 2.8 Exercises 69 2.8.1 EfficacyofSmallClassSizeinEarlyEducation 69 2.8.2 ChangingMindsonGayMarriage 71 2.8.3 SuccessofLeaderAssassinationasaNaturalExperiment 73 3 Measurement 75 3.1 MeasuringCivilianVictimizationduringWartime 75 3.2 HandlingMissingDatainR 78 3.3 VisualizingtheUnivariateDistribution 80 3.3.1 BarPlot 80 3.3.2 Histogram 81 3.3.3 BoxPlot 85 3.3.4 PrintingandSavingGraphs 87 3.4 SurveySampling 88 3.4.1 TheRoleofRandomization 89 3.4.2 NonresponseandOtherSourcesofBias 93 3.5 MeasuringPoliticalPolarization 96 3.6 SummarizingBivariateRelationships 97 3.6.1 ScatterPlot 98 3.6.2 Correlation 101 3.6.3 Quantile–QuantilePlot 105 3.7 Clustering 108 3.7.1 MatrixinR 108 3.7.2 ListinR 110 3.7.3 Thek-MeansAlgorithm 111 3.8 Summary 115 3.9 Exercises 116 3.9.1 ChangingMindsonGayMarriage:Revisited 116 3.9.2 PoliticalEfficacyinChinaandMexico 118 3.9.3 VotingintheUnitedNationsGeneralAssembly 120 4 Prediction 123 4.1 PredictingElectionOutcomes 123 4.1.1 LoopsinR 124 Contents ix 4.1.2 GeneralConditionalStatementsinR 127 4.1.3 PollPredictions 130 4.2 LinearRegression 139 4.2.1 FacialAppearanceandElectionOutcomes 139 4.2.2 CorrelationandScatterPlots 141 4.2.3 LeastSquares 143 4.2.4 RegressiontowardstheMean 148 4.2.5 MergingDataSetsinR 149 4.2.6 ModelFit 156 4.3 RegressionandCausation 161 4.3.1 RandomizedExperiments 162 4.3.2 RegressionwithMultiplePredictors 165 4.3.3 HeterogenousTreatmentEffects 170 4.3.4 RegressionDiscontinuityDesign 176 4.4 Summary 181 4.5 Exercises 182 4.5.1 PredictionBasedonBettingMarkets 182 4.5.2 ElectionandConditionalCashTransfer PrograminMexico 184 4.5.3 GovernmentTransferandPovertyReductioninBrazil 187 5 Discovery 189 5.1 TextualData 189 5.1.1 TheDisputedAuthorshipofTheFederalistPapers 189 5.1.2 Document-TermMatrix 194 5.1.3 TopicDiscovery 195 5.1.4 AuthorshipPrediction 200 5.1.5 CrossValidation 202 5.2 NetworkData 205 5.2.1 MarriageNetworkinRenaissanceFlorence 205 5.2.2 UndirectedGraphandCentralityMeasures 207 5.2.3 Twitter-FollowingNetwork 211 5.2.4 DirectedGraphandCentrality 213 5.3 SpatialData 220 5.3.1 The1854CholeraOutbreakinLondon 220 5.3.2 SpatialDatainR 223 5.3.3 ColorsinR 226 5.3.4 USPresidentialElections 228 5.3.5 ExpansionofWalmart 231 5.3.6 AnimationinR 233 5.4 Summary 235 5.5 Exercises 236 5.5.1 AnalyzingthePreamblesofConstitutions 236 5.5.2 InternationalTradeNetwork 238 5.5.3 MappingUSPresidentialElectionResultsoverTime 239
Description: