Conjoint Analysis using R

Posted on Updated on

Combining concepts from Choice theory (Economics) and applications of Parameter estimation (Statistics), Conjoint analysis is a quantitative market research technique which helps identify which attributes of a given product or service users most value.

Employed in the areas of Product development, Marketing (Product positioning), and Operations, knowing user choices allow to improve product offering (by modeling and testing focused set of product options), and best allocate resources.

A conjoint study typically starts with identifying an approach exercise starts with the design of a Conjoint research following by estimating model parameters. This involves breaking the product/service into constituent parts (attributes) to build profiles and gathering preference data through surveys.

Design of conjoint study typically involves the below steps:

  1. Recognize approach (type of analysis required in the situation)
  2. Identify attributes and assign levels
  3. Define utilities and design experiment (based on choice situations)
  4. Parameter estimation and synthesize results
  5. Develop implications

For the purposes of the post, I present a hypothetical situation where I want to develop the next billion-dollar cola product based on what attributes cola drinkers most like.


In this survey, I had 10 respondents rate 8 profiles of cola products. The profiles have been created based on varying levels of a cola drink’s taste profile. These distinguishing attributes used are “kola (the kola nut bitter to ending in vanilla-sweet flavor)”, “fizz (effervescence)”, “sweetness” and “price”.


Based on the profiles presented, the respondents were asked to provide their liking for each of the product profile.



#Read in the files
profiles <- read.csv("profiles.csv", header=T, na.strings=c(""))
preferences <- read.csv("preference.csv", header=T, na.strings=c(""))

#Add the levels
levels <- c("low", "high", "low", "high","low", "high","1.5", "2")
levels.df <- data.frame(levels)

For simplicity, the four attributes identified have been configured with levels across the flavor profiles and price.

Once the data is loaded, we will call the conjoint function by passing three inputs:

  1. (dataset: preference) Survey responses from participants with ratings across each of the flavor+price profile created
  2. (dataset: profiles) Profiles created based on varying levels of flavors and price points
  3. (dataframe: levels.df) Levels across the four attributes

Plot: Utilities of individual attributes
Plot: Average importance of factors

Looks like based on survey results, the most appreciated attributes are fizz followed by kola. So we might want to create a cola with higher fizz and kola flavor (like Thums up). Sweetness is relatively less important but based on the positive utility of the attribute “sweetness”, there are respondents who have liked a sweeter cola. Of all the attributes, the least important is price. This in fact could be observed by eyeballing the two paired profiles which have the same taste profile but a different price (for example: profile 1 & profile 2 are such a pair). This means people are ok to pay $0.5 premium for the cola which most appeal to them.

The challenges in setting up a conjoint study are often complex and multi-faceted. In a more realistic setting, typically products or services have both more attributes and levels which leads to a huge number of possible profiles to evaluate for candidacy. And during evaluation of these large set of profiles by respondents, the results are subject to various type of response bias.

Data aggregation using dplyr package in R (sample snippet)

Posted on Updated on

In this post, I am using SuperStore data to explore some of the data wrangling functions from these two packages.

The data is in the form of an Excel workbook with three sheets namely – Orders, Returns, and Region. I am loading the three different sheets into separate datasets into R, joining them and performing necessary aggregations.


#For accessing and dumping excel files

#Used for data wrangling

#Used for data wrangling

#Load three individuals sheets into separate datasets 


# Sum of Sales by Product Category 
 group_by(Product.Category) %>%
 summarise(Total.Sales = sum(Sales)) %>%


#Join data sets and aggregate as per requirement

# Inner join the two data sets Order and Users by Region and look at Total Sales by Region
data.final %
 group_by(Region) %>%
 summarise(Total.Sales = sum(Sales))


Spotfire: Passing value from HTML/JavaScript to Document Property

Posted on Updated on

Reference snippet to pass a radio button value into Spotfire context, that is into a Document Property.

<FORM><B>Select date for filtering:</B>
<INPUT id=”pack1″
value=”N” CHECKED type=radio name=pack1>
Date 1<BR>
<INPUT id=”pack2″
value=”Y” type=radio name=pack1>Date 2

HTML to Document Property

Link to sample Spotfire analyses

R Shiny – Histogram

Posted on

Using Shiny Package in R to develop a Histogram with binning.



Histogram – RStudio Shiny

Going beyond base Tableau – Unofficial Add-ons

Posted on Updated on

Advanced data visualization tools such as Tableau and Spotfire bundle capabilities such as Table calculations and Custom expressions respectively and make new dimensions of viewing data possible. Further, interactivity and customization which could be brought into dashboards with the use of parameters (in Tableau) and property controls (in Spotfire) set apart these visual analytic products from conventional BI query and analysis tools.

However, apart from out-of-the-box functionality, more could be achieved using these tools with some minor tweaks. One such example is to use phpGrid in a webpage (as part of the Tableau dashboard) as a user interface to show dynamic views depending on the data entered on the grid.

Below is a simple gantt chart which has parameters to filter data. Interactivity is limited to filtering data depending on the filters which only work on the data from the source file.


However, there are a couple of ways we could update the data into a database with these parameters. First is to use a phpgrid to interact with the database using the refresh button action. And another method is to use the GET method (to pass parameters as part of the URL) using the dashboard webpage.

By Ryan Robitaille


By Russell Christopher