I'm trying to follow these instructions: https://docs.google.com/spreadsheets/d/1Piw0Fk0XCWBJOHhC8NsljvIPywaBmLdNa8QpEV75fHQ/edit#gid=777817907 to do a choice-based conjoint analysis with multiple regression like they did, but with my own data.
With my data, I have 3 attributes where 2 of them have 3 levels and the remaining one has 2 levels.
Initially, this analysis should be done using an MCMC Hierarchical Bayesian Multinomial Logit Model. However, I'm interested in reproducing their steps by using only the simpler version with multiple regression (I saw there's a way to use this MCMC HB model with the "bayesm" package in R but I haven't found a simple way to do it...)
In my data, I also have one column per level instead of one column per attribute like they did. The problem is that, since they only use 2 levels per attribute in their example, they have no problem in encoding everything with 1s and 0s. How would I go about this with 3 levels per attribute?
Also, when it comes to calculating the last table in the third Sheet ("3. Calculation of utilities"), I have no idea on how to begin to do this with more than 2 levels per attribute. How would you do it?
By saving the table from the third Sheet below where it says "Let's put all the data together" into an XLSX file and then running the following in R, you can reproduce their regressions:
library(tidyverse) library(broom) library(janitor) library(readxl) library(writexl) df <- read_xlsx("data.xlsx") %>% janitor::clean_names() final_data <- df %>% pivot_longer(!choice_set, names_to = "respondent_id", values_to = "selection") %>% pivot_wider(names_from = "choice_set", values_from = "selection") %>% janitor::clean_names() %>% mutate(respondent_id = str_sub(respondent_id, start = 2, end = 3), respondent_id = ifelse(respondent_id != 10, str_sub(respondent_id, start = 1, end = 1), respondent_id)) fit1 <- lm(your_choice ~ brand + pack_format + fat_content + price_per_litre, data = final_data) tidy(fit1)
Thank you so much.