UseR! Chris Chapman Elea McDonnell Feit R for Marketing Research and Analytics Use R! SeriesEditors: RobertGentleman KurtHornik GiovanniParmigiani Moreinformationaboutthisseriesathttp://www.springer.com/series/6991 Use R! Kolaczyk/Csa´rdi:StatisticalAnalysisofNetworkDatawithR(2014) Nolan/TempleLang:XMLandWebTechnologiesforDataScienceswithR(2014) Willekens:MultistateAnalysisofLifeHistorieswithR(2014) Cortez:ModernOptimizationwithR(2014) Eddelbuettel:SeamlessRandC++IntegrationwithRcpp(2013) Bivand/Pebesma/Go´mez-Rubio:AppliedSpatialDataAnalysiswithR (2nded.2013) vandenBoogaart/Tolosana-Delgado:AnalyzingCompositionalDatawithR (2013) Nagarajan/Scutari/Le`bre:BayesianNetworksinR(2013) Chris Chapman Elea McDonnell Feit • R for Marketing Research and Analytics 123 ChrisChapman EleaMcDonnellFeit Google,Inc. LeBowCollegeofBusiness Seattle,WA,USA DrexelUniversity [email protected] Philadelphia,PA,USA [email protected] ISSN2197-5736 ISSN2197-5744 (electronic) UseR! ISBN978-3-319-14435-1 ISBN978-3-319-14436-8 (eBook) DOI10.1007/978-3-319-14436-8 LibraryofCongressControlNumber:2014960277 SpringerChamHeidelbergNewYorkDordrechtLondon (cid:2)c SpringerInternationalPublishingSwitzerland2015 Thisworkissubjecttocopyright.AllrightsarereservedbythePublisher,whetherthewholeorpartof thematerialisconcerned,specificallytherightsoftranslation,reprinting,reuseofillustrations,recitation, broadcasting,reproductiononmicrofilmsorinanyotherphysicalway,andtransmissionorinformation storageandretrieval,electronicadaptation,computersoftware,orbysimilarordissimilarmethodology nowknownorhereafterdeveloped. Theuseofgeneraldescriptivenames,registerednames,trademarks,servicemarks,etc.inthispublication doesnotimply,evenintheabsenceofaspecificstatement,thatsuchnamesareexemptfromtherelevant protectivelawsandregulationsandthereforefreeforgeneraluse. Thepublisher,theauthorsandtheeditorsaresafetoassumethattheadviceandinformationinthisbook arebelievedtobetrueandaccurateatthedateofpublication.Neitherthepublishernortheauthorsor theeditorsgiveawarranty,expressorimplied,withrespecttothematerialcontainedhereinorforany errorsoromissionsthatmayhavebeenmade. Printedonacid-freepaper SpringerInternationalPublishingAGSwitzerlandispartofSpringerScience+BusinessMedia (www.springer.com) Praise for R for Marketing Research and Analytics RforMarketingResearchandAnalyticsistheperfectbookforthoseinterestedin driving success for their business and for students looking to get an introduction toR.Whilemanybookstakeapurelyacademicapproach,Chapman(Google)and Feit(formerlyofGMandtheModellers)knowexactlywhatisneededforpractical marketing problem solving. I am an expert R user, yet had never thought about a textbookthatprovidesthesoup-to-nutswaythatChapmanandFeitdo:showhowto loadadataset,exploreitusingvisualizationtechniques,analyzeitusingstatistical models, and then demonstrate the business implications. It is a book that I wish I hadwritten. EricBradlow,K.P.ChaoProfessor,Chairperson,WhartonMarketingDepartment andCo-Director,WhartonCustomerAnalyticsInitiative RforMarketingResearchandAnalyticsprovidesanexcellentintroductiontotheR statisticalpackageformarketingresearchers. Thisisamust-havebookforanyone who seriously pursues analytics in the field of marketing. R is the software gold standard in the research industry, and this book provides an introduction to R and showshowtoruntheanalysis. Topicsrangefromgraphicsandexploratorymethods toconfirmatorymethodsincludingstructuralequationmodeling,allillustratedwith data. Agreatcontributiontothefield! Greg Allenby, Helen C. Kurtz Chair in Marketing, Professor of Marketing, ProfessorofStatistics,OhioStateUniversity ChrisChapman’sandEleaFeit’sengagingandauthoritativebooknicelyfillsagap in the literature. At last we have an accessible book that presents core marketing researchmethodsusingthetoolsandvernacularofmoderndatascience. Thebook will enable marketing researchers to up their game by adopting the R statistical computingenvironment. Anddatascientistswithaninterestinmarketingproblems nowhaveareferencethatspeakstothemintheirlanguage. JamesGuszcza,ChiefDataScientist,DeloitteConsulting–US v vi PraiseforRforMarketingResearchandAnalytics FinallyahighlyaccessibleguideforgettingstartedwithR. FeitandChapmanhave applied years of lessons learned to developing this easy-to-use guide, designed to quickly build a strong foundation for applying R to sound analysis. The authors succeed in demystifying R by employing a likeable and practical writing style, along with sensible organization and comfortable pacing of the material. In addi- tiontocoveringallthemostimportantanalysistechniques,theauthorsaregenerous throughoutinprovidingtipsforoptimizingR’sefficiencyandidentifyingcommon pitfalls. With this guide, anyone interested in R can begin using it confidently in a short period of time for analysis, visualization, and for more advanced analytics procedures. RforMarketingResearchandAnalyticsistheperfectguideandrefer- encetextforthecasualandadvanceduseralike. Matt Valle, Executive Vice President, Global Key Account Management – GfK Preface WeareheretohelpyoulearnRformarketingresearchandanalytics. Risagreatchoiceformarketinganalysts.Itoffersunsurpassedcapabilitiesforfit- tingstatisticalmodels.Itisextensibleandisabletoprocessdatafrommanydifferent systems,inavarietyofforms,forbothsmallandlargedatasets.TheRecosystem includesthewidestavailablerangeofestablishedandemergingstatisticalmethods aswellas visualization techniques. Yetthe useof Rinmarketing lags other fields suchasstatistics,econometrics,psychology,andbioinformatics.Withyourhelp,we hopetochangethat! Thisbookisdesignedfortwoaudiences:practicingmarketingresearchersandan- alystswhowanttolearnR,andstudentsorresearchersfromotherfieldswhowant toreviewselectedmarketingtopicsinanRcontext. What are the prerequisites? Simply that you are interested in R for marketing, are conceptuallyfamiliarwithbasicstatisticalmodelssuchaslinearregression,andare willing to engage in hands-on learning. This book will be particularly helpful to analystswhohavesomedegreeofprogrammingexperienceandwishtolearnR.In Chap.1wedescribeadditionalreasonstouseR(andafewreasonsperhapsnot to useR). Thehands-onpartisimportant.Weteachconceptsgraduallyinasequenceacross the first seven chapters and ask you to type our examples as you work; this book is not a cookbook-style reference. We spend some time (as little as possible) in PartIonthebasicsoftheRlanguageandthenturninPartIItoapplied,real-world marketing analytics problems. Part III presents a few advanced marketing topics. Every chapter shows off the power of R, and we hope each one will teach you somethingnewandinteresting. Specificfeaturesofthisbookareasfollows: • It is organized around marketing research tasks. Instead of generic examples, weputmethodsintothecontextofmarketingquestions. vii viii Preface • Wepresumeonlybasicstatisticsknowledgeanduseaminimumofmathemat- ics. This book is designed to be approachable for practitioners and does not dwell on equations or mathematical details of statistical models (although we givereferencestothosetexts). • ThisisadidacticbookthatexplainsstatisticalconceptsandtheRcode.Wewant youtounderstandwhatwe’redoingandlearnhowtoavoidcommonproblems inbothstatisticsandR.Weintendthebooktobereadableandtofulfilladif- ferentneedthanreferencesandcookbooksavailableelsewhere. • The applied chapters demonstrate progressive model building. We do not present “the answer” but instead show how an analyst might realistically con- duct analyses in successive steps where multiple models are compared for statisticalstrengthandpracticalutility. • The chapters include visualization as a part of core analyses. We don’t regard visualization as a stand-alone topic; rather, we believe it is an integral part of dataexplorationandmodelbuilding. • YouwilllearnmorethanjustR.Inadditiontocoremodels,weincludetopics suchasstructuralmodelsandtransactionanalysisthatmaybenewanduseful evenforexperiencedanalysts. • The book reflects both traditional and Bayesian approaches. Core models are presentedwithtraditional(frequentist)methods,whilelatersectionsintroduce Bayesianmethodsforlinearmodelsandconjointanalysis. • Mostoftheanalysesusesimulateddata,whichprovidespracticeintheRlan- guagealongwithadditionalinsightintothestructureofmarketingdata.Ifyou are inclined, you can change the data simulation and see how the statistical modelsareaffected. • Where appropriate, we call out more advanced material on programming or modelssothatyoumayeitherskipitorreadit,asyoufindappropriate.These sectionsareindicatedby*intheirtitles(suchasThisisanadvancedsection*). What do we not cover? For one, this book teaches R for marketing and does not teachmarketingresearchinitself.Wediscussmanymarketingtopicsbutomitoth- ersthatwouldsimplyrepeattheanalyticmethodsinR.Asnotedabove,weapproach statisticalmodelsfromaconceptualpointofviewandskipthemathematics.Afew specialized topics have been omitted due to complexity and space; these include customer lifetime value models and econometric time series models. Overall, we believe the analyses here represent a great sample of marketing research and ana- lyticspractice.Ifyoulearntoperformthese,you’llbewellequippedtoapplyRin manyareasofmarketing. Whyarewetherightteachers?We’veusedRanditspredecessorSforacombined 27yearssince1997anditisourprimaryanalyticsplatform.Weperformmarketing analysesofallkindsinR,rangingfromsimpledatasummariestocomplexanalyses involvingthousandsoflinesofcustomcodeandnewlycreatedmodels. Preface ix We’ve also taught R to many people. This book grew from courses the authors have presented at American Marketing Association (AMA) events including the AcademyofMarketingAnalyticsatEmoryUniversityandseveralyearsoftheAd- vanced Research Techniques Forum (ART Forum). We have also taught R at the Sawtooth Software Conference and to students and industry collaborators at the WhartonSchool.Wethankthosemanystudentsfortheirfeedbackandbelievethat theirexperienceswillbenefityou. Acknowledgements Wewanttogivespecialthanksheretopeoplewhomadethisbookpossible.Firstare allthestudentsfromourtutorialsandclassesovertheyears.Theyprovidedvaluable feedback,andwehopetheirexperienceswillbenefityou. In the marketing academic and practitioner community, we had valuable feedback from Ken Deal, Fred Feinberg, Shane Jensen, Jake Lee, Dave Lyon, and Bruce McCullough. Chris’s colleagues in the research community at Google provided extensive feed- back on portions of the book. We thank Mario Callegaro, Marianna Dizik, Rohan Gifford, Tim Hesterberg, Shankar Kumar, Norman Lemke, Paul Litvak, Katrina Panovich,MartaRey-Babarro,KerryRodden,DanRussell,AngelaScho¨rgendorfer, StevenScott,BobSilverstein,GillWard,JohnWebb,andYoriZwolsfortheiren- couragementandcomments. ThestaffandeditorsatSpringerhelpedussmooththeprocess,especiallyHannah Bracken,JonGurstelle,andtheUseR!serieseditors. Muchofthisbookwaswritteninpublicanduniversitylibraries,andwethankthem for their hospitality alongside their unsurpassed literary resources. Portions of the book were written during pleasant days at the New Orleans Public Library, New YorkPublicLibrary,ChristophKellerJr.LibraryattheGeneralTheologicalSem- inary in New York, University of California San Diego Geisel Library, University of Washington Suzzallo and Allen Libraries, Sunnyvale Public Library, and most particularly,wherethefirstwords,code,andoutlinewerewritten,alongwithmuch morelater,theTokyoMetropolitanCentralLibrary. Ourfamiliessupportedusinweekendsandnightsofediting,andtheyenduredmore discussionofRthanisfairforanylayperson.Thankyou,Cristi,Maddie,Jeff,and Zoe. Mostimportantly,wethankyou,thereader.We’regladyou’vedecidedtoinvestigate R,andwehopetorepayyoureffort.Let’sstart! NewYork,NYandSeattle,WA ChrisChapman Philadelphia,PA EleaMcDonnellFeit November2014
Description: