Uncategorized

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.

Conjoint_Analysis_Awaited_Cola

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”.

Conjoint_Analysis_Profiles

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

Conjoint_Analysis_Preferences

install.packages("conjoint")
library("conjoint")
setwd("C:/R")

#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
Conjoint(y=preferences[,4:11],x=profiles[,6:9],z=levels.df)

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

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.

setwd("C:/R")

#For accessing and dumping excel files
install.packages("openxlsx")
library(openxlsx) 

#Used for data wrangling
install.packages("dplyr")
library(dplyr) 

#Used for data wrangling
install.packages("tidyr")
library(tidyr)

#Load three individuals sheets into separate datasets 
superstore.wb

datastore

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

aggr_1

#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))
data.final

aggr_2

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>
<P>
<INPUT id=”pack1″
onclick=”document.getElementById(‘145de349837d49f493cc9ec23743b05f’).value=document.getElementById(‘pack1’).value”
value=”N” CHECKED type=radio name=pack1>
Date 1<BR>
<INPUT id=”pack2″
onclick=”document.getElementById(‘145de349837d49f493cc9ec23743b05f’).value=document.getElementById(‘pack2’).value”
value=”Y” type=radio name=pack1>Date 2
</FORM>
</P>


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.

R_Shiny_Histogram

Reference:

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.

Gantt_Chart_1

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

http://ryrobes.com/tableau/tableau-phpgrid-an-almost-instant-gratification-data-entry-tool/

By Russell Christopher

http://tableaulove.tumblr.com/post/27627548817/another-method-to-update-data-from-inside-tableau