“Listen, I—I appreciate this whole seduction scene you’ve got going, but let me give you a tip: I’m a sure thing. OK?” —JULIA ROBERTS AS VIVIAN WARD IN Pretty Woman (1990) Mass marketing treats all customers as one group. Oneto-one marketing focuses on one customer at a time. Target marketing to selected groups of customers or market segments lies between mass marketing and oneto-one marketing. Target marketing involves directing marketing activities to those customers who are most likely to buy
Trang 2About This eBook
ePUB is an open, industry-standard format for
eBooks However, support of ePUB and its many
features varies across reading devices and applications.Use your device or app settings to customize the
presentation to your liking Settings that you can
customize often include font, font size, single or doublecolumn, landscape or portrait mode, and figures thatyou can click or tap to enlarge For additional
information about the settings and features on yourreading device or app, visit the device manufacturer’sWeb site
Many titles include programming code or
configuration examples To optimize the presentation ofthese elements, view the eBook in single-column,
landscape mode and adjust the font size to the smallestsetting In addition to presenting code and
configurations in the reflowable text format, we haveincluded images of the code that mimic the presentationfound in the print book; therefore, where the reflowableformat may compromise the presentation of the codelisting, you will see a “Click here to view code image”link Click the link to view the print-fidelity code image
To return to the previous page viewed, click the Backbutton on your device or app
Trang 3Marketing Data Science
Modeling Techniques in Predictive
Analytics with R and Python
T HOMAS W M ILLER
Trang 4Publisher: Paul Boger
Editor-in-Chief: Amy Neidlinger
Executive Editor: Jeanne Glasser Levine
Operations Specialist: Jodi Kemper
Cover Designer: Alan Clements
Managing Editor: Kristy Hart
Manufacturing Buyer: Dan Uhrig
©2015 by Thomas W Miller
Published by Pearson Education, Inc
Old Tappan New Jersey 07675
For information about buying this title in bulk
quantities, or for special sales opportunities (which mayinclude electronic versions; custom cover designs; andcontent particular to your business, training goals,
marketing focus, or branding interests), please contactour corporate sales department at
All rights reserved No part of this book may be
reproduced, in any form or by any means, without
Trang 5permission in writing from the publisher.
Printed in the United States of America
First Printing May 2015
ISBN-10: 0-13-388655-7
ISBN-13: 978-0-13-388655-9
Pearson Education LTD
Pearson Education Australia PTY, Limited
Pearson Education Singapore, Pte Ltd
Pearson Education Asia, Ltd
Pearson Education Canada, Ltd
Pearson Educación de Mexico, S.A de C.V
Pearson Education—Japan
Pearson Education Malaysia, Pte Ltd
Library of Congress Control Number: 2015937911
Trang 62 Predicting Consumer Choice
3 Targeting Current Customers
4 Finding New Customers
10 Assessing Brands and Prices
11 Utilizing Social Networks
Trang 712 Watching Competitors
13 Predicting Sales
14 Redefining Marketing Research
A Data Science Methods
A.1 Database Systems and Data PreparationA.2 Classical and Bayesian Statistics
A.3 Regression and Classification
A.4 Data Mining and Machine Learning
A.5 Data Visualization
A.6 Text and Sentiment Analysis
A.7 Time Series and Market Response Models
B Marketing Data Sources
Trang 8B.9 Interviews
B.10 Focus Groups
B.11 Field Research
C Case Studies
C.1 AT&T Choice Study
C.2 Anonymous Microsoft Web DataC.3 Bank Marketing Study
C.4 Boston Housing Study
C.5 Computer Choice Study
C.6 DriveTime Sedans
C.7 Lydia E Pinkham Medicine CompanyC.8 Procter & Gamble Laundry SoapsC.9 Return of the Bobbleheads
C.10 Studenmund’s Restaurants
C.11 Sydney Transportation Study
C.12 ToutBay Begins Again
C.13 Two Month’s Salary
C.14 Wisconsin Dells
C.15 Wisconsin Lottery Sales
C.16 Wikipedia Votes
Trang 9D Code and UtilitiesBibliography
Index
Trang 10“Everybody loses the thing that made them It’s evenhow it’s supposed to be in nature The brave men stayand watch it happen, they don’t run.”
—QUVENZHANÉ WALLIS AS HUSHPUPPY IN Beasts of the
Southern Wild (2012)
Writers of marketing textbooks of the past would
promote “the marketing concept,” saying that marketing
is not sales or selling Rather, marketing is a matter ofunderstanding and meeting consumer needs They
would distinguish between “marketing research,” a
business discipline, and “market research,” as in
economics And marketing research would sometimes
be described as “marketing science” or “marketing
engineering.”
Ignore the academic pride and posturing of the past.Forget the linguistic arguments Marketing and sales,marketing and markets, research and science—they areone In a world transformed by information technologyand instant communication, data rule the day
Data science is the new statistics, a blending of
modeling techniques, information technology, and
business savvy Data science is also the new look of
marketing research
Trang 11In introducing marketing data science, we choose topresent research about consumers, markets, and
marketing as it currently exists Research today meansgathering and analyzing data from web surfing,
crawling, scraping, online surveys, focus groups, blogsand social media Research today means finding
answers as quickly and cheaply as possible
Finding answers efficiently does not mean we mustabandon notions of scientific research, sampling, orprobabilistic inference We take care while designingmarketing measures, fitting models, describing researchfindings, and recommending actions to management.There are times, of course, when we must engage inprimary research We construct survey instruments andinterview guides We collect data from consumer
samples and focus groups This is traditional marketingresearch—custom research, tailored to the needs of eachindividual client or research question
The best way to learn about marketing data science is towork through examples This book provides a readyresource and reference guide for modeling techniques
We show programmers how to build on a foundation ofcode that works to solve real business problems
The truth about what we do is in the programs we write.The code is there for everyone to see and for some todebug To promote student learning, programs includestep-by-step comments and suggestions for taking
analyses further Data sets and computer programs are
Trang 12available from the website for the Modeling Techniques
series at http://www.ftpress.com/miller/
When working on problems in marketing data science,some things are more easily accomplished with Python,others with R And there are times when it is good tooffer solutions in both languages, checking one againstthe other Together, Python and R make a strong
combination for doing data science
Most of the data in this book come from public domainsources Supporting data for many cases come from theUniversity of California–Irvine Machine Learning
Repository and the Stanford Large Network DatasetCollection I am most thankful to those who provideaccess to rich data sets for research
I have learned from my consulting work with ResearchPublishers LLC and its ToutBay division, which
promotes what can be called “data science as a service.”Academic research and models can take us only so far.Eventually, to make a difference, we need to implementour ideas and models, sharing them with one another.Many have influenced my intellectual development overthe years There were those good thinkers and goodpeople, teachers and mentors for whom I will be forevergrateful Sadly, no longer with us are Gerald Hahn
Hinkle in philosophy and Allan Lake Rice in languages
at Ursinus College, and Herbert Feigl in philosophy atthe University of Minnesota I am also most thankful toDavid J Weiss in psychometrics at the University of
Trang 13Minnesota and Kelly Eakin in economics, formerly atthe University of Oregon.
Thanks to Michael L Rothschild, Neal M Ford, Peter R.Dickson, and Janet Christopher who provided
invaluable support during our years together at theUniversity of Wisconsin–Madison While serving asdirector of the A C Nielsen Center for Marketing
Research, I met the captains of the marketing researchindustry, including Arthur C Nielsen, Jr himself I metand interviewed Jack Honomichl, the industry’s
historian, and I met with Gil Churchill, first author ofwhat has long been regarded as a key textbook in
marketing research I learned about traditional
marketing research at the A C Nielsen Center for
Marketing Research, and I am most grateful for theexperience of working with its students and executiveadvisory board members Thanks go as well to Jeff
Walkowski and Neli Esipova who worked with me inexploring online surveys and focus groups when thosemethods were just starting to be used in marketingresearch
After my tenure with the University of Wisconsin–Madison, I built a consulting practice My company,Research Publishers LLC, was co-located with the
former Chamberlain Research Consultants SharonChamberlain gave me a home base and place to practicethe craft of marketing research It was there that initialconcepts for this book emerged:
Trang 14What could be more important to a business than understanding its customers, competitors, and markets? Managers need a
coherent view of things With consumer research, product
management, competitive intelligence, customer support, and
management information systems housed within separate
departments, managers struggle to find the information they
need Integration of research and information functions makes
more sense (Miller 2008).
My current home is the Northwestern University School
of Professional Studies I support courses in three
graduate programs: Master of Science in Predictive
Analytics, Advanced Certificate in Data Science, andMaster of Arts in Sports Administration Courses inmarketing analytics, database systems and data
preparation, web and network data science, and datavisualization provide inspiration for this book
I expect Northwestern’s graduate programs to prosper
as they forge into new areas, including analytics
entrepreneurship and sports analytics Thanks to
colleagues and staff who administer these exceptionalgraduate programs, and thanks to the many studentsand fellow faculty from whom I have learned
Amy Hendrickson of TEXnology Inc applied her craft,making words, tables, and figures look beautiful in print
—another victory for open source Lorena Martin
reviewed the book and provided much needed feedback.Roy Sanford provided advice on statistical explanations.Candice Bradley served dual roles as a reviewer and
copyeditor for all books in the Modeling Techniques
series I am grateful for their guidance and
encouragement
Trang 15Thanks go to my editor, Jeanne Glasser Levine, andpublisher, Pearson/FT Press, for making this and other
books in the Modeling Techniques series possible Any
writing issues, errors, or items of unfinished business,
of course, are my responsibility alone
My good friend Brittney and her daughter Janiya keep
me company when time permits And my son Daniel isthere for me in good times and bad, a friend for life Mygreatest debt is to them because they believe in me.Thomas W Miller
Glendale, California
April 2015
Trang 162.2 Correlation Heat Map for Explanatory Variables inthe Sydney Transportation Study
2.3 Logistic Regression Density Lattice
2.4 Using Logistic Regression to Evaluate the Effect ofPrice Changes
3.1 Age and Response to Bank Offer
3.2 Education Level and Response to Bank Offer
3.3 Job Type and Response to Bank Offer
3.4 Marital Status and Response to Bank Offer
3.5 Housing Loans and Response to Bank Offer
3.6 Logistic Regression for Target Marketing (DensityLattice)
3.7 Logistic Regression for Target Marketing
Trang 174.2 Response to Term Deposit Offers by Market
5.6 Logistic Regression for the Probability of Switching(Confusion Mosaic)
5.7 A Classification Tree for Predicting Consumer
Choices about Service Providers
5.8 Logistic Regression for Predicting Customer
Retention (ROC Curve)
5.9 Nạve Bayes Classification for Predicting CustomerRetention (ROC Curve)
5.10 Support Vector Machines for Predicting CustomerRetention (ROC Curve)
6.1 A Product Similarity Ranking Task
6.2 Rendering Similarity Judgments as a Matrix
Trang 186.3 Turning a Matrix of Dissimilarities into a
Perceptual Map
6.4 Indices of Similarity and Dissimilarity between
Pairs of Binary Variables
6.5 Map of Wisconsin Dells Activities Produced by
8.1 Dodgers Attendance by Day of Week
8.2 Dodgers Attendance by Month
8.3 Dodgers Weather, Fireworks, and Attendance
8.4 Dodgers Attendance by Visiting Team
8.5 Regression Model Performance: Bobbleheads andAttendance
9.1 Market Basket Prevalence of Initial Grocery Items9.2 Market Basket Prevalence of Grocery Items by
Category
9.3 Market Basket Association Rules: Scatter Plot
9.4 Market Basket Association Rules: Matrix BubbleChart
9.5 Association Rules for a Local Farmer: A NetworkDiagram
Trang 1910.1 Computer Choice Study: A Mosaic of Top Brandsand Most Valued Attributes
10.2 Framework for Describing Consumer Preferenceand Choice
10.3 Ternary Plot of Consumer Preference and Choice10.4 Comparing Consumers with Differing Brand
11.5 Degree Distributions for Network Models
11.6 Network Modeling Techniques
12.1 Competitive Intelligence: Spirit Airlines Flying High13.1 Scatter Plot Matrix for Restaurant Sales and
Trang 2014.1 Competitive Analysis for the Custom ResearchProvider
14.2 A Model for Strategic Planning
14.3 Data Sources in the Information Supply Chain14.4 Client Information Sources and the World WideWeb
14.5 Networks of Research Providers, Clients, and
Intermediaries
A.1 Evaluating the Predictive Accuracy of a BinaryClassifier
A.2 Linguistic Foundations of Text Analytics
A.3 Creating a Terms-by-Documents Matrix
B.1 A Framework for Marketing Measurement
B.2 Hypothetical Multitrait-Multimethod Matrix
B.3 Framework for Automated Data Acquisition
B.4 Demographic variables from Mintel survey
B.5 Sample questions from Mintel movie-going surveyB.6 Open-Ended Questions
B.7 Guided Open-Ended Question
B.8 Behavior Check List
B.9 From Check List to Click List
B.10 Adjective Check List
B.11 Binary Response Questions
B.12 Rating Scale for Importance
B.13 Rating Scale for Agreement/Disagreement
Trang 21B.24 Paired Comparison Choice Task
B.25 Choice Set with Three Product Profiles
B.26 Menu-based Choice Task
B.27 Elimination Pick List
B.28 Factors affecting the validity of experimentsB.29 Interview Guide
B.30 Interview Projective Task
C.1 Computer Choice Study: One Choice Set
Trang 227.1 Analysis of Deviance for New Product Field Test:Procter & Gamble Laundry Soaps
8.1 Bobbleheads and Dodger Dogs
8.2 Regression of Attendance on Month, Day of Week,and Bobblehead Promotion
9.1 Market Basket for One Shopping Trip
9.2 Association Rules for a Local Farmer
10.1 Contingency Table of Top-ranked Brands and MostValued Attributes
10.2 Market Simulation: Choice Set Input
10.3 Market Simulation: Preference Shares in a
Hypothetical Four-brand Market
12.1 Competitive Intelligence Sources for Spirit Airlines
Trang 2313.1 Fitted Regression Model for Restaurant Sales
13.2 Predicting Sales for New Restaurant Sites
A.1 Three Generalized Linear Models
B.1 Levels of measurement
C.1 Variables for the AT&T Choice Study
C.2 Bank Marketing Study Variables
C.3 Boston Housing Study Variables
C.4 Computer Choice Study: Product Attributes
C.5 Computer Choice Study: Data for One IndividualC.6 Hypothetical profits from model-guided vehicleselection
C.7 DriveTime Data for Sedans
C.8 DriveTime Sedan Color Map with Frequency
Counts
C.9 Variables for the Laundry Soap Experiment
C.10 Cross-Classified Categorical Data for the LaundrySoap Experiment
C.11 Variables for Studenmund’s Restaurants
C.12 Data for Studenmund’s Restaurants
C.13 Variables for the Sydney Transportation StudyC.14 ToutBay Begins: Website Data
C.15 Diamonds Data: Variable Names and Coding RulesC.16 Dells Survey Data: Visitor Characteristics
C.17 Dells Survey Data: Visitor Activities
Trang 24C.18 Wisconsin Lottery Data
C.19 Wisconsin Casino Data
C.20 Wisconsin ZIP Code Data
C.21 Top Sites on the Web, September 2014
Trang 251.1 Measuring and Modeling Individual Preferences (R)1.2 Measuring and Modeling Individual Preferences(Python)
2.1 Predicting Commuter Transportation Choices (R)2.2 Predicting Commuter Transportation Choices
(Python)
3.1 Identifying Customer Targets (R)
4.1 Identifying Consumer Segments (R)
4.2 Identifying Consumer Segments (Python)
5.1 Predicting Customer Retention (R)
6.1 Product Positioning of Movies (R)
6.2 Product Positioning of Movies (Python)
6.3 Multidimensional Scaling Demonstration: US Cities(R)
6.4 Multidimensional Scaling Demonstration: US Cities(Python)
6.5 Using Activities Market Baskets for Product
Positioning (R)
6.6 Using Activities Market Baskets for Product
Positioning (Python)
6.7 Hierarchical Clustering of Activities (R)
7.1 Analysis for a Field Test of Laundry Soaps (R)
Trang 268.1 Shaking Our Bobbleheads Yes and No (R)
8.2 Shaking Our Bobbleheads Yes and No (Python)9.1 Market Basket Analysis of Grocery Store Data (R)9.2 Market Basket Analysis of Grocery Store Data(Python to R)
10.1 Training and Testing a Hierarchical Bayes Model(R)
10.2 Analyzing Consumer Preferences and Building aMarket Simulation (R)
11.1 Network Models and Measures (R)
11.2 Analysis of Agent-Based Simulation (R)
11.3 Defining and Visualizing a Small-World Network(Python)
11.4 Analysis of Agent-Based Simulation (Python)12.1 Competitive Intelligence: Spirit Airlines FinancialDossier (R)
13.1 Restaurant Site Selection (R)
13.2 Restaurant Site Selection (Python)
D.1 Conjoint Analysis Spine Chart (R)
D.2 Market Simulation Utilities (R)
D.3 Split-plotting Utilities (R)
D.4 Utilities for Spatial Data Analysis (R)
D.5 Correlation Heat Map Utility (R)
D.6 Evaluating Predictive Accuracy of a Binary
Classifier (Python)
Trang 281 Understanding Markets
“What makes the elephant guard his tusk in the mistymist, or the dusky dusk? What makes a muskrat guardhis musk?”
—BERT LAHR AS COWARDLY LION IN The Wizard of Oz
(1939)
While working on the first book in the Modeling
Techniques series, I moved from Madison, Wisconsin to
Los Angeles I had a difficult decision to make aboutmobile communications I had been a customer of U.S.Cellular for many years I had one smartphone and twodata modems (a 3G and a 4G) and was quite satisfiedwith U.S Cellular services In May of 2013, the companyhad no retail presence in Los Angeles and no 4G service
in California Being a data scientist in need of an
example of preference and choice, I decided to assess
my feelings about mobile phone services in the Los
Angeles market
The attributes in my demonstration study were the
mobile provider or brand, startup and monthly costs, ifthe provider offered 4G services in the area, whether theprovider had a retail location nearby, and whether theprovider supported Apple, Samsung, or Nexus phones inaddition to tablet computers Product profiles,
representing combinations of these attributes, were
Trang 29easily generated by computer My consideration setincluded AT&T, T-Mobile, U.S Cellular, and Verizon Igenerated sixteen product profiles and presented them
to myself in a random order Product profiles, theirattributes, and my ranks, are shown in table 1.1
Table 1.1 Preference Data for Mobile
Communication Services
A linear model fit to preference rankings is an example
of traditional conjoint analysis, a modeling technique
designed to show how product attributes affect
purchasing decisions Conjoint analysis is really
conjoint measurement Marketing analysts present
product profiles to consumers Product profiles are
defined by their attributes By ranking, rating, or
choosing products, consumers reveal their preferencesfor products and the corresponding attributes that
define products The computed attribute importancevalues and part-worths associated with levels of
attributes represent measurements that are obtained as
a group or jointly—thus the name conjoint analysis The
Trang 30task—ranking, rating, or choosing—can take many
forms
When doing conjoint analysis, we utilize sum contrasts,
so that the sum of the fitted regression coefficients
across the levels of each attribute is zero The fittedregression coefficients represent conjoint measures of
utility called part-worths Part-worths reflect the
strength of individual consumer preferences for eachlevel of each attribute in the study Positive part-worthsadd to a product’s value in the mind of the consumer.Negative part-worths subtract from that value When wesum across the part-worths of a product, we obtain ameasure of the utility or benefit to the consumer
To display the results of the conjoint analysis, we use a
special type of dot plot called the spine chart, shown in
figure 1.1 In the spine chart, part-worths can be
displayed on a common, standardized scale across
attributes The vertical line in the center, the spine, isanchored at zero
Trang 32Figure 1.1 Spine Chart of Preferences for Mobile
Communication Services
The part-worth of each level of each attribute is
displayed as a dot with a connecting horizontal line,extending from the spine Preferred product or servicecharacteristics have positive part-worths and fall to theright of the spine Less preferred product or servicecharacteristics fall to the left of the spine
The spine chart shows standardized part-worths andattribute importance values The relative importance ofattributes in a conjoint analysis is defined using theranges of part-worths within attributes These
importance values are scaled so that the sum across allattributes is 100 percent Conjoint analysis is a
measurement technology Part-worths and attributeimportance values are conjoint measures
What does the spine chart say about this consumer’spreferences? It shows that monthly cost is of
considerable importance Next in order of importance is4G availability Start-up cost, being a one-time cost, is
Trang 33much less important than monthly cost This consumerranks the four service providers about equally And
having a nearby retail store is not an advantage Thisconsumer is probably an Android user because we seehigher importance for service providers that offer
Samsung phones and tablets first and Nexus second,while the availability of Apple phones and tablets is oflittle importance
This simple study reveals a lot about the consumer—itmeasures consumer preferences Furthermore, the
linear model fit to conjoint rankings can be used to
predict what the consumer is likely to do about mobilecommunications in the future
Traditional conjoint analysis represents a modelingtechnique in predictive analytics Working with groups
of consumers, we fit a linear model to each individual’sratings or rankings, thus measuring the utility or part-worth of each level of each attribute, as well as the
relative importance of attributes
The measures we obtain from conjoint studies may beanalyzed to identify consumer segments Conjoint
measures can be used to predict each individual’s
choices in the marketplace Furthermore, using conjointmeasures, we can perform marketplace simulations,exploring alternative product designs and pricing
policies Consumers reveal their preferences in
responses to surveys and ultimately in choices theymake in the marketplace
Trang 34Marketing data science, a specialization of predictiveanalytics or data science, involves building models ofseller and buyer preferences and using those models tomake predictions about future marketplace behavior.Most of the examples in this book concern consumers,but the ways we conduct research—data preparation andorganization, measurements, and models—are relevant
to all markets, consumer and business markets alike
business-to-Managers often ask about what drives buyer choice.They want to know what is important to choice or whichfactors determine choice To the extent that buyer
behavior is affected by product features, brand, andprice, managers are able to influence buyer behavior,increasing demand, revenue, and profitability
Product features, brands, and prices are part of the
mobile phone choice problem in this chapter But thereare many other factors affecting buyer behavior—
unmeasured factors and factors outside managementcontrol Figure 1.2 provides a framework for
understanding marketplace behavior—the choices ofbuyers and sellers in a market
Trang 35Figure 1.2 The Market: A Meeting Place for Buyers
and Sellers
A market, as we know from economics, is the locationwhere or channel through which buyers and sellers gettogether Buyers represent the demand side, and sellersthe supply side To predict what will happen in a market
—products to be sold and purchased, and the clearing prices of those products—we assume that
market-sellers are profit-maximizers, and we study the pastbehavior and characteristics of buyers and sellers We
Trang 36build models of market response This is the job of
marketing data science as we present it in this book
Ask buyers what they want, and they may say, the best
of everything Ask them what they would like to spend, and they may say, as little as possible There are
limitations to assessing buyer willingness to pay andproduct preferences with direct-response rating scales,
or what are sometimes called self-explicative scales.Simple rating scale items arranged as they often are,with separate questions about product attributes,
brands, and prices, fail to capture tradeoffs that are
fundamental to consumer choice To learn more frombuyer surveys, we provide a context for responding andthen gather as much information as we can This is whatconjoint and choice studies do, and many of them do itquite well In the appendix B (pages 312 to 337) we
provide examples of consumer surveys of preferenceand choice
Conjoint measurement, a critical tool of marketing datascience, focuses on buyers or the demand side of
markets The method was originally developed by Luceand Tukey (1964) A comprehensive review of conjointmethods, including traditional conjoint analysis, choice-based conjoint, best-worst scaling, and menu-basedchoice, is provided by Bryan Orme (2013) Primary
applications of conjoint analysis fall under the headings
of new product design and pricing research, which wediscuss later in this book
Trang 37Exhibits 1.1 and 1.2 show R and Python programs foranalyzing ranking or rating data for consumer
preferences The programs perform traditional conjointanalysis The spine chart is a customized data
visualization for conjoint and choice studies We showthe R code for making spine charts in appendix D,
exhibit D.1 starting on page 400 Using standard R
graphics, we build this chart one point, line, and textstring at a time The precise placement of points, lines,and text is under our control
Exhibit 1.1 Measuring and Modeling Individual
Preferences (R)
Click here t o v iew code image
# Traditional Conjoint Analysis (R)
# R preliminaries to get the user-defined
function for spine chart:
# place the spine chart code file
<R_utility_program_1.R>
# in your working directory and execute it by
# source("R_utility_program_1.R")
# Or if you have the R binary file in your
working directory, use
# load(file="mtpa_spine_chart.Rdata")
Trang 38# spine chart accommodates up to 45
part-worths on one page
# |part-worth| <= 40 can be plotted directly
on the spine chart
# |part-worths| > 40 can be accommodated
retail = c("Retail NO","Retail YES"),
Trang 39apple = c("Apple NO","Apple YES"),
samsung = c("Samsung NO","Samsung YES"),
google = c("Nexus NO","Nexus YES")),
nalternatives = 1, nblocks=1, seed=9999)
print(questionnaire(provider.survey)) # print survey design for review
sink("questions_for_survey.txt") # send survey
to external text file
questionnaire(provider.survey)
sink() # send output back to the screen
# user-defined function for plotting
descriptive attribute names
effect.name.map <- function(effect.name) {
if(effect.name=="brand") return("Mobile
Service Provider")
if(effect.name=="startup") return("Start-up Cost")
if(effect.name=="monthly") return("Monthly Cost")
if(effect.name=="service") return("Offers 4G Service")
Trang 40if(effect.name=="retail") return("Has Nearby Retail Store")
if(effect.name=="apple") return("Sells Apple Products")
if(effect.name=="samsung") return("Sells Samsung Products")
# main effects model specification
main.effects.model <- {ranking ~ brand +
startup + monthly + service +
retail + apple + samsung + google}