UseR! Antonio Páez Geneviève Boisjoly Discrete Choice Analysis with R Use R! SeriesEditors RobertGentleman,23andMeInc.,SouthSanFrancisco,USA KurtHornik,DepartmentofFinance,AccountingandStatistics,WU WirtschaftsuniversitätWien,Vienna,Austria GiovanniParmigiani,Dana-FarberCancerInstitute,Boston,USA ThisseriesofinexpensiveandfocusedbooksonRisaimedatpractitioners.Books candiscusstheuseofRinaparticularsubjectarea(e.g.,epidemiology,econometrics, psychometrics) or as it relates to statistical topics (e.g., missing data, longitudinal data).Inmostcases,bookscombineLaTeXandRsothatthecodeforfiguresand tablescanbeputonawebsite.Authorsshouldassumeabackgroundassuppliedby Dalgaard’s Introductory Statistics with R or other introductory books so that each bookdoesnotrepeatbasicmaterial. HowtoSubmitYourProposal Bookproposalsandmanuscriptsshouldbesubmittedtooneofthepublishingeditors inyourregionperemail–forthelistofstatisticseditorsbytheirlocationpleasesee https://www.springer.com/gp/statistics/contact-us.Allsubmissionsshouldincludea completedBookProposalForm. For general and technical questions regarding the series and the submission process please contact Faith Su ([email protected]) or Veronika Rosteck ([email protected]). · Antonio Páez Geneviève Boisjoly Discrete Choice Analysis with R AntonioPáez GenevièveBoisjoly McMasterUniversity PolytechniqueMontréal Hamilton,ON,Canada Montréal,QC,Canada ISSN 2197-5736 ISSN 2197-5744 (electronic) UseR! ISBN 978-3-031-20718-1 ISBN 978-3-031-20719-8 (eBook) https://doi.org/10.1007/978-3-031-20719-8 ©TheEditor(s)(ifapplicable)andTheAuthor(s),underexclusivelicensetoSpringerNature SwitzerlandAG2022 Thisworkissubjecttocopyright.AllrightsaresolelyandexclusivelylicensedbythePublisher,whether thewholeorpartofthematerialisconcerned,specificallytherightsoftranslation,reprinting,reuse ofillustrations,recitation,broadcasting,reproductiononmicrofilmsorinanyotherphysicalway,and transmissionorinformationstorageandretrieval,electronicadaptation,computersoftware,orbysimilar ordissimilarmethodologynowknownorhereafterdeveloped. Theuseofgeneraldescriptivenames,registerednames,trademarks,servicemarks,etc.inthispublication doesnotimply,evenintheabsenceofaspecificstatement,thatsuchnamesareexemptfromtherelevant protectivelawsandregulationsandthereforefreeforgeneraluse. Thepublisher,theauthors,andtheeditorsaresafetoassumethattheadviceandinformationinthisbook arebelievedtobetrueandaccurateatthedateofpublication.Neitherthepublishernortheauthorsor theeditorsgiveawarranty,expressedorimplied,withrespecttothematerialcontainedhereinorforany errorsoromissionsthatmayhavebeenmade.Thepublisherremainsneutralwithregardtojurisdictional claimsinpublishedmapsandinstitutionalaffiliations. ThisSpringerimprintispublishedbytheregisteredcompanySpringerNatureSwitzerlandAG Theregisteredcompanyaddressis:Gewerbestrasse11,6330Cham,Switzerland Preface “Wouldyoutellme,please,whichwayIoughttogofrom here?” “Thatdependsagooddealonwhereyouwanttogetto,” saidtheCat. “Idon’tmuchcarewhere—”saidAlice. “Thenitdoesn’tmatterwhichwayyougo,”saidtheCat. “—solongasIgetSOMEWHERE,”Aliceaddedasan explanation. “Oh,you’resuretodothat,”saidtheCat,“ifyouonly walklongenough.” —LewisCarroll,AliceinWonderland “Weareourchoices.” —Jean-PaulSartre Choices,Choices,Choices AccordingtoSartre,weareourchoices,whichimpliesthatwehaveatleastacertain ability to choose what we are. The choices we make have important implications for how we interact with each other and the world. It is a truism to say that we live in a time when resources grow increasingly scarce—when, as a species, we aretestingthelimitstogrowth.Inthiscontext,thewaywemakechoicesisinfor- mativeaboutourindividualpreferencesandwherewe,collectively,aregoing.For thisreasonitisimportanttounderstandchoice-makingandindividualpreferences. Thisincludesbehavioraroundroutineactivities,suchasdecidinghowtotravelfor everydaypurposes(forinstancewalkingorcycling,driving,orusingtransit).Aswell, longertermdecisionsareofinterest,suchasthefrequencywithwhichwetravelby plane; the choice to live in a distant suburb where rent is low but transportation is v vi Preface expensive,orinacity’scenterwhereaccessibilityishighbutspaceisatapremium; whethertocontractmoreexpensivebutenvironmentallylessdamaginglowimpact energysources;whethertobuyhybrid,electric,orgasolinevehicles.Thesearejust some examples of the myriads of choices that we all make in the course of a life- time,andthatcollectivelyimpacttheeconomy,ournaturalenvironment,andsocial relationships. Understandingdecision-makingisalsoimportanttoensurethattheworld,ormore accurately the social institutions that collectively represent us in our interactions with the world, can better accommodate and possibly even nudge our preferences towardssociallydesirableoutcomes.Whatdoourchoicestellusaboutourlongterm sustainabilityasanadvancedtechnologicalspecies?Whattrade-offsaremembersof thepublicwillingtocontemplatewhenchoosingalternativemobility?Isittherange ofanewelectricvehicle?Oritsprice?Thetimeittakestochargeitsbattery?The satisfaction of being green? Do consumers prefer more range in electric vehicles, andhowmucharetheywillingtopayforit?Doesthetrade-offjustifytheincrease in production costs? Should governments subsidize purchases of efficient heating systems?Ifso,whatistheeffectofacertainamountinsubsidy? These questions are important for governments and businesses as they try to understandpublicresponsestofiscal,engineering,orproductiondecisions. Inverysimpleterms,discretechoiceanalysisisafamilyofmodelingtechniques that are useful to understand behavior when decisions concern alternatives that are indivisible and mutually exclusive. These techniques are particularly relevant whenthealternativesarebundlesofattributesthatcollectivelyhaveanexplicitprice but whose individual features may only have implicit prices. In this way, discrete choiceanalysisrepresentsaformofhedonicpriceanalysis,atooltounderstandthe preferencesofindividualsinthepresenceofimplicitmarkets(Wong2018). Butwhatareprices?Broadlyspeaking,apriceisaquantityofferedinpayment foroneunitofagoodorservice.Economistsspeculatethatearlyeconomieswere basedonbartering.Thisassumesrelativelysimpleeconomicsystems,andyetones wherepeoplealreadyhavestoppedbeinggeneraliststobecomespecialistsofsome sort,andthereforesometimesdesiretoexchangegoodsand/orserviceswithothers. Someonewhospecializesinmakingbreadprobablyhasonlylimitedtimetogrow wheat,ortominesalt,ortomakeshoes.Thesamethinggoesforeveryonewhohas specializedatsomething,andcannotmeetalltheirneedsusingonlytheirownlabor andresources. Imagineforamomentthatyouhavespecializedatbaking.Someofyourneighbors needbreadandmaybewillingtoofferaquantityofsomethinginexchangeforsome ofit.Thepersonwhobreedschickenmaybewillingtoofferonechickenforthree loafs of freshly baked bread. Is that a fair exchange? How can anyone determine whetherthatexchangeissensible?Well,ifbothpartiesagreethatonechickenisa satisfactory exchange for three loafs of bread, we can maybe say that the price of oneloafofbreadisonethirdofachicken. Imaginenowthatyou,thebaker,needsomeonetomendyourroof,andtherefore requiretheservicesofyetanothermemberofyourcommunitywhohasspecialized ingoingupladdersandthatchingroofs.Howmanyloafsofbreadshouldyouoffer Preface vii thispersonformakingsurethatyoudonothaveleakswhenitrains?Andwhatif thethatcherhasallergiesandcannoteatbread?Butmaybethispersonwouldagree tofixyourroofifhereceivedchickensinexchange. Asyoucanimagine,thissimplesystemcanrapidlybecomeunwieldy[andmay actuallyneverhaveexistedinrealityinthisform;seeGraeber(2011)].Besidesthe needtocoordinatemultipleactorsinwhatpotentiallyismultipletwo-waytransac- tions(baker-to-thatcherbecomesbaker-to-farmer-to-thatcher),thesituationisfurther complicatedbytherelianceofbarteringonsomekindoftrustsystem:asaperson offering a good or a service in a bartering system, there are no simple ways of ensuringthequalityoftheexchange!Forexample,whatifthethatcherisacrook,or thefarmergivesyoudiseasedchickensinexchangeforyourtop-notch,high-quality, mouth-wateringloafsofbread?Insmallsystems,whereagentscanrecognizeeach other, trust is enforced by reputation—if the thatcher is crooked, or the farmer is knowntofeedleadtothepoultry,otheractorscanavoidtransactionswiththem.If leaks begin as soon as it starts to rain and this becomes known, people will soon avoiddoingbusinesswiththethatcher. As these simple examples illustrate, even simple bartering systems are compli- catedwaysofsettingprices,somethingthatbecomesincreasinglydifficult(except inveryexceptionalsituations)whenaneconomyproduceshundreds,thousands,or evenmoredifferentproductsandservices. (AninterestingexceptionisthetimewhenPepsicobarteredwiththeSovietUnion; see this news item from 1990.1 In this case, soft drinks were bartered for ships and vodka [Why did barter make sense in this situation? Hint: the Soviet ruble’s officialexchangeratecomparedtoothercurrencieswasmoreorlessmeaningless; Wyczalkowski(1950)]). Somethingelseneedstoemergetofacilitatecomplicatedexchangesinacomplex economy,thatsomethingbeingmoney. PriceMechanisms,or,IsMoneytheRootofAllEvil Asentimentcommonlyexpressedinnumerousculturesthroughouthistoryisadisap- provalofgreed.Awell-knownexampleis1Timothy6:10,whichwarnsthatthelove ofmoneyistherootofallofevil.Andwhileloveofmoneyforitsownsakemaynot strikeusasvirtuous,itisalmostcertainthatnocomplexeconomycanexistwithout the invention of money. The complexities of bartering make clear the need for a commonstandardforexchange.Insteadofneedingtofigureouthowmanyshoesa chickenisworthandhowmanychickensareequivalenttoanewroof,everythingis 1https://www.nytimes.com/1990/04/09/business/international-report-pepsi-will-be-bartered-for- ships-vodka-deal-with-soviets.html. viii Preface measuredusingthesamemetric:shells,deerleather,2 rupees,pesos,bilimbiques,3 ordollars. Thelimitationsofbarteringhelptoexplain(ifinasomewhatsimplisticfashion) the necessity of monetary systems. A common currency frees the maker of shoes fromtheneedtocalculatethecostofhisnewroofinchickens.Butitdoesnotexplain howpricesaresetinthecommoncurrency. Pricemechanismsdependtoalargeextentontheinstitutionalframework.Several suchframeworksexist. Think for example of a centrally planned economy, where prices for goods or servicesaresetbyadesignatedagent.ThiscouldbetheElderoftheVillage.TheElder of the village decides how many pesos people should pay for shoes (alternatively, howmuchtheshoemakercanchargeforapairofshoes),andhowmuchyoushould pay a thatcher for each hour of work (or for a completed roof). Everyone in this kindofsetuppraysthattheElderknowswhattheyaredoing,andthepotentialfor mistakesclearlyisfarfromnegligible.IntheSovietUnionpricesweresetusingso- calledmaterialbalances,whichaimedatbalancingtheinputstotheplannedoutputs. As history shows, this approach was not successful. There are several reasons for this, including ideological limitations in the mathematical tools used to calculate balances,aswellasthelimitationsofsuchplanning,whichisinherentlyrigidand doesnotallowfordeviationsfromtheplan(whatifyouendupneedingtwopairsof shoesinsteadofonlyoneornone?). Inafreemarketeconomy,ontheotherhand,pricesarelefttofloatwithnointer- ventionfromcentralplanningagencies.Thereisavoluminousliteratureexplaining howthissystemcanallocateresourcesefficiently.Althoughmuchofthisliteratureis riddledwithfantasiesthatwishawayexternalitiesandothermarketfailures,itdoes contain numerous valuable insights, including the notion that prices are signals of howdesirableagoodorserviceis,andtheincentivestoproducemoreorlessofit. Economistsexplainthisfundamentalrelationshipusingtheconceptsofdemand andsupply. Thebasicassumptioninthisrelationship(whichhappenstoholdinmanycases) is that the level of demand for a good or service (the quantity that consumers are willing to purchase) declines as the price increases. On the side of producers and providersofgoodsandservices,thelevelofsupply(thequantitythattheyarewilling toproduce)increaseswithprice.Demandandsupply,then,areinfluencedbyprice, buttheydonothappeninisolation—rather,theyinteracttosetprices.Aconsumer cannot single-handedly demand that a good/service be sold at a certain (i.e., low) pricewhenmanyconsumersarewillingtopayasomewhathigherpriceforthesame (otherwiseonecouldbuyabrandnewGameStation2000for25dollarsorwhatever itcoststoproduceit).Likewise,aproducerofagoodorproviderofaservicecannot expect to set a high price for a good/service when other producers are willing to sellatalowerprice.Thereare,ofcourse,deviationstothiskindofrule,whichcan befairlycommonoraberrantdependingontheinstitutionalframework.Ontheone 2https://commons.wikimedia.org/wiki/File:Tang_Dynasty_30_Kuan_banknote.jpg. 3https://es.wikipedia.org/wiki/Moneda_revolucionaria. Preface ix Fig.1 Supplyanddemand relationships hand,monopoliesandcartelscanmanipulatepricesonbehalfofproducers,whereas single-payerhealthcaremanipulatespricesinfavorofpatients. The intersection of the supply and demand curves determines simultaneously pricesand thequantityofagood/serviceproduced/consumed.Sinceprices“float”, they can adjust to changes in supply and/or demand. In Fig. 1, for example, when demandforagoodorservice(sayroofs)increases,thereisanincentiveforthatchers toworkmorehours.Sincethereisalimitednumberofhoursthatthatcherscanwork (thereisscarcity),thisisreflectedinahigherprice,aslongasthosewhocanafford itarewillingtopaymoreforascarcebutdesirableservice. Between centrally planned economies and pure free markets exists an endless range of mixed economies, where prices are often left to float but within limits or withothercorrectivemechanisms,suchassubsidiesortaxes. Formostofus,themostfamiliarsituationofpricemechanismswouldbeinthe formoffreeormixedeconomies,aftermostcentrallyplannedeconomiesattheend ofthe20thcenturycollapsedorchangedtowardsmoremarket-basedeconomies(or in some cases towards systems of crony capitalism). An underlying assumption in these systems is that a market exists for the good or service in question, that is, a mediumwheregoodsorservicescanbeexchanged.Marketsexistformanythings: formilk,forbread,forinsurance,andforcomplexfinancialinstrumentsthatnoone reallyunderstands,suchasderivatives.Ontheotherhand,marketsdonotexplicitly exist for particular features of composite products or services, and therefore the willingnesstopayofconsumersforelementsofaspecificgoodcannotbediscerned directly. (In reality, even something as seemingly simple as milk can be seen as a bundle:thebrand,thefatcontent,additionofvitamins,etc.)