tag:blogger.com,1999:blog-590043897961646114.post8563245913133715026..comments2017-11-06T07:33:46.940-08:00Comments on Engaging Market Research: Let's Do Some Hierarchical Bayes Choice Modeling in R!Joel Cadwellhttp://www.blogger.com/profile/14946447393733294251noreply@blogger.comBlogger56125tag:blogger.com,1999:blog-590043897961646114.post-32716251040681149232016-08-04T17:03:20.315-07:002016-08-04T17:03:20.315-07:00ok. That's the problem. I am using the mean va...ok. That's the problem. I am using the mean value for beta. Applying them to user 1 would not necessarily agree with the experimental results. bhomasshttps://www.blogger.com/profile/17522424219219324418noreply@blogger.comtag:blogger.com,1999:blog-590043897961646114.post-2660540185210466542016-08-04T13:25:44.893-07:002016-08-04T13:25:44.893-07:00So, there are three alternatives available in each...So, there are three alternatives available in each choice set. You can pick only one of the following: Brand A, Brand B, or None of These. Toward the end of the post, I have listed the estimated coefficients used to calculate the utilities for each of these options. None of These gets a zero because of the coding. The Brand A utility is the sum of the appeal of Brand A and its price level. The same applies to Brand B. <br /><br />Although every respondent has their unique estimates, let us use the average values as an example. Both Brand A and B have negative values, meaning that at their highest price point (because of the dummy coding) None of These is more likely to be selected. Brand B stays negative regardless of price (-1.99+1.39<0). Brand A, however, goes positive for both of its lower price points. <br /><br />Remember that share is exp(Brand A+Brand A Price)/[1+exp(Brand A + Brand A Price)+exp(Brand B + Brand B Price)], where exp(0)=1 represents None of These.Joel Cadwellhttps://www.blogger.com/profile/13462586727133296404noreply@blogger.comtag:blogger.com,1999:blog-590043897961646114.post-25296359375160870752016-08-03T22:23:58.572-07:002016-08-03T22:23:58.572-07:00Thank you Joel for the post. I got thru the entire...Thank you Joel for the post. I got thru the entire A3 code in Rossi's book, so I believe I do have a handle on hierarchical bayesian model in general. I am confused on several points. 1) You put the choice of brand A and B in the design matrix. In my view, you would have 4 dependent variables made up by brand-price combinations, and the (brandA,B,none) categories should be the regressant or results which represent the classification at the output. 2) based on the standard multinomial logistic regression approach given in wikipedia, there would be different sets of betas for each possible outcome. However, you listed only one set of betas, which seems to imply you only use one set of beta for all possible outcomes. 3) I plugged in the beta values and the design matrix numbers in excel, and the predicted results (largest numbers) do not at all agree with the Y values: [1] 2 2 1 3 1 3 1 3 2. If you could kindly enlighten me where did I go astray. bhomasshttps://www.blogger.com/profile/17522424219219324418noreply@blogger.comtag:blogger.com,1999:blog-590043897961646114.post-4841977196519268972016-07-19T08:37:12.478-07:002016-07-19T08:37:12.478-07:00Once you have the coefficients, you return to the ...Once you have the coefficients, you return to the multinomial logit model and substitute these estimates into the equation. I did not cover any of this in my post. However, this material is presented for aggregate models in the book "R for Marketing Research and Analytics" by Chris Chapman and Elea McDonnell Feit. Here is a link to one of their slides http://r-marketing.r-forge.r-project.org/slides/chapter13-phillyR/ConjointR20150418.html#/15 (you will need to repeat this for each respondent when fitting a hierarchical model). Additional links can be found on the first slide of this presentation. Good luck.Joel Cadwellhttps://www.blogger.com/profile/13462586727133296404noreply@blogger.comtag:blogger.com,1999:blog-590043897961646114.post-34657781917277350612016-07-18T23:32:16.594-07:002016-07-18T23:32:16.594-07:00Hi, I am not sure if you will see this, I tried to...Hi, I am not sure if you will see this, I tried to replicate ur code, but I am stuck at the very end when I wish to use the generated model to make prediction. Could you please provide some guidance on how to make predict in bayesm package? Thank youDongyang Fuhttps://www.blogger.com/profile/02691387468827309191noreply@blogger.comtag:blogger.com,1999:blog-590043897961646114.post-52499920216328150372016-07-02T10:20:18.303-07:002016-07-02T10:20:18.303-07:00Both concepts, goodness-of-fit and relative import...Both concepts, goodness-of-fit and relative importance, flow easily from a linear model estimated using some form of least squares minimization (which is why the bayesm R package does not have functions for either one).Joel Cadwellhttps://www.blogger.com/profile/13462586727133296404noreply@blogger.comtag:blogger.com,1999:blog-590043897961646114.post-25467314404871206172016-07-02T02:00:04.341-07:002016-07-02T02:00:04.341-07:00Is there in the bayesm Package an Function to say ...Is there in the bayesm Package an Function to say something about the Goodness of Fit? Coulnd't find something in the documentation. And the importance of the relativ importance of the features, or can i use the span like in the TCA?<br /><br />Thank you.Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-590043897961646114.post-4996834241431389652016-06-30T06:55:46.272-07:002016-06-30T06:55:46.272-07:00You are free to use whatever coding you prefer.You are free to use whatever coding you prefer.Joel Cadwellhttps://www.blogger.com/profile/13462586727133296404noreply@blogger.comtag:blogger.com,1999:blog-590043897961646114.post-1772233195047934242016-06-30T01:32:51.898-07:002016-06-30T01:32:51.898-07:00Or would effect-coding be more useful?Or would effect-coding be more useful?Alexander K.noreply@blogger.comtag:blogger.com,1999:blog-590043897961646114.post-3437791217987031772016-06-30T01:05:57.967-07:002016-06-30T01:05:57.967-07:00I added now three columns.
design1 <- matrix(c...I added now three columns.<br /><br />design1 <- matrix(c(<br />1,0,0,0,1,0,0,1,0,1,0,0,0,1,<br />0,1,0,0,1,0,0,0,1,0,0,0,1,0,<br />0,0,1,0,0,0,0,1,0,1,0,0,1,0,<br />0,0,0,0,0,0,0,0,0,0,0,0,0,0)<br />,nrow=4,ncol=14,byrow = TRUE)<br /><br />I thought your first two columns are for the Brand A and Brand B. But i see what you mean. Cause my None-Option is identical with my reference. So i have to adapt my designmatrix to make the difference clear between the None-Option and my reference product. <br /><br />So i could three columns for the alternatives. Which could lead to problems with interpretation. Or i could codify some category without an reference niveau, or?<br />Alexander K.noreply@blogger.comtag:blogger.com,1999:blog-590043897961646114.post-78381549378099098782016-06-29T09:14:52.413-07:002016-06-29T09:14:52.413-07:00I have copied the relevant section from the above ...I have copied the relevant section from the above post here:<br /><br />On to the Design Matrices<br /><br />So far, we have a data frame with the categorical dependent variable called choice. Now we need to attach a design matrix for each of the nine choice sets. It might be easiest to explain by presenting the R code. Design #1 is for the first choice set. There are 6 columns for the 6 parameters to be estimated in this design. That is, there are 2 dfs for the three alternatives, plus 2 dfs for Brand A price and 2 dfs for Brand B price. I have used dummy coding so that the third alternative, Neither, is the base with only 0s. The columns, in order, represent the effects for Brand A, Brand B, Brand A Price 1, Brand A Price 2, Brand B Price 1, and Brand B Price 2. Brand A and B appear in every choice set; only the effects for price vary.Joel Cadwellhttps://www.blogger.com/profile/13462586727133296404noreply@blogger.comtag:blogger.com,1999:blog-590043897961646114.post-90921849025157734002016-06-29T08:14:31.604-07:002016-06-29T08:14:31.604-07:00Hi,
what do you mean with, "Where are your ...Hi, <br /><br />what do you mean with, "Where are your columns for these three alternatives?". Which three alternatives, each row is a alternative. <br /><br />Sincerly, <br />AlexAlexander K.noreply@blogger.comtag:blogger.com,1999:blog-590043897961646114.post-8259162436221227992016-06-29T07:37:54.476-07:002016-06-29T07:37:54.476-07:00I am assuming that design1 describes a choice set ...I am assuming that design1 describes a choice set that a respondent would be shown. Then, the number of rows would indicate three alternatives were shown with the last row representing "none of these" (e.g., in my example, the first row was Brand A and the second row was Brand B where A and B stand for different brands such as R and Python or BMW and VW). Where are your columns for these three alternatives?Joel Cadwellhttps://www.blogger.com/profile/13462586727133296404noreply@blogger.comtag:blogger.com,1999:blog-590043897961646114.post-28311497820017035482016-06-29T00:06:21.337-07:002016-06-29T00:06:21.337-07:00Hi,
thank your for your Feedback i will show you...Hi, <br /><br />thank your for your Feedback i will show you what i've done to be sure to be right. <br /><br />I have 5 Price Levels (-10%,-5%,0,+5%,+10%), 2 Levels for Price Communication (Yes/No), 4 Levels for Questions, 3 Levels for Additinal Benefits and 2 Levels for Sponsoring (Yes/No). I choosed as reference level the actual product so i can show the improvements. <br /><br />I will construct the design-matrix like this. <br /><br />design1 <- matrix(c( <br /> 0,1,0,0,1,0,1,0,0,0,1,<br /> 0,1,0,0,0,1,0,0,0,1,0,<br /> 0,0,0,0,1,0,1,0,0,1,0,<br /> 0,0,0,0,0,0,0,0,0,0,0) <br /> ,nrow=4,ncol=11,byrow = TRUE)<br /><br />Is this correct or sensful? You safed my life with this post here. <br /><br />Thank you.Alexander K.noreply@blogger.comtag:blogger.com,1999:blog-590043897961646114.post-13166592507434551442016-06-27T08:18:35.102-07:002016-06-27T08:18:35.102-07:00In choice models, where there are only a small num...In choice models, where there are only a small number of price levels, it makes sense to treat price as a categorical factor (e.g., one requires only 2 dummy variables to code 3 levels of price as shown above). Of course, price can be treated as a continuous variable. In fact, you can randomly generate price as a uniform variable over a specified range and then fit a polynomial function or use a log transformation.Joel Cadwellhttps://www.blogger.com/profile/13462586727133296404noreply@blogger.comtag:blogger.com,1999:blog-590043897961646114.post-81079489193202729662016-06-26T08:26:41.058-07:002016-06-26T08:26:41.058-07:00Hi,
i have a question. How have i to construct t...Hi, <br /><br />i have a question. How have i to construct the design matrix if i have 5 features with different levels. For example Feature one has five levels and so on. Needs $X then five columns for the level price or habe i just one column with numbers one to five for the levels. So if i would be right, then should i have for $X round abound 25 Columns or? And if i plot the loglike i miss the typical Burn in in the plot. I have just a fluctuation around a constant. Is this normal? I constructed my Designplan with XLstat for Excel.<br /><br />Thank you for your Feedback.Alexander K.noreply@blogger.comtag:blogger.com,1999:blog-590043897961646114.post-84383009436096280172016-05-04T15:30:54.755-07:002016-05-04T15:30:54.755-07:00My post was meant only to show how one might use R...My post was meant only to show how one might use R to analyze hierarchical choice data. I avoided the details because they are just far too complicated for a blog. You might take a look at Justin Esarey at Rice University. He provides video and R script for a course in Bayesian Statistics (http://jee3.web.rice.edu/teaching.htm) that covers hierarchical models.Joel Cadwellhttps://www.blogger.com/profile/13462586727133296404noreply@blogger.comtag:blogger.com,1999:blog-590043897961646114.post-86294848441000189372016-05-04T12:33:48.083-07:002016-05-04T12:33:48.083-07:00Hi Joel,
Thank your for this great post and good ...Hi Joel,<br /><br />Thank your for this great post and good illustration.<br />I am an absolute beginner and after days of reading I am still trying to understand how the estimation procedure actually works (what is done by the function rhierMnlRwMixture (or others in bayesm package)?). <br />I know that for parametric models I need to prespecify a prior distribution on the coefficients and a prior on the parameters of the coefficients and additionally a likelihood function. Did I get it right that then the posterior distribution is derived analytically and finally draws are taken from that posterior?<br /><br />Can you please help me to understand the process?Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-590043897961646114.post-51976518794500758862015-08-07T07:46:41.060-07:002015-08-07T07:46:41.060-07:00It has been some time since I looked at the rscale...It has been some time since I looked at the rscaleUsage function, but as I recall, it did not output individual-level estimates. I never pursued the topic because I do not agree that halo effects are measurement error. Uniformly high brand ratings reflect brand equity, and uniformly high importance ratings represent greater product involvement. You will find a number of posts on this blog outlining my views on halo effects.Joel Cadwellhttps://www.blogger.com/profile/13462586727133296404noreply@blogger.comtag:blogger.com,1999:blog-590043897961646114.post-76021555401828570722015-08-07T01:02:08.640-07:002015-08-07T01:02:08.640-07:00Oh yes, that's right - thank you Joel for this...Oh yes, that's right - thank you Joel for this important note!<br /><br />Just one last question in this context:<br />In package bayesm one finds another function called 'rscaleUsage' for analyzing data on scale usage heterogeniety.<br /><br />Runnig this function on some data I am able to retrieve the adjusted mean values:<br /><br />Res <- rscaleUsage(...) <br />Res$mudraw<br /><br />Is there also a possiblity to retrieve the adjusted scale values for each respondent on each variable? It seems to me that the function does not return those values - but I wondered if I can calculate those values. But I must admit that this exceeds my theoretical knowledge here.<br /><br />Best regards<br />Dirk<br /><br /><br /><br />Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-590043897961646114.post-32995956708234328012015-08-05T07:06:34.381-07:002015-08-05T07:06:34.381-07:00Yes, but be careful about the indices. As you show...Yes, but be careful about the indices. As you show in your R code, betadraw is a cube defined as respondents x coefficients x draws. So, you first decide how many draws to discard. Let's say you compare the coefficients listed in the above post and decide to eliminate the first 500 draws. Now, use apply to average across the last index for draws:<br /><br />estimate<-apply(out$betadraw[,,501:2000], c(1,2), mean)Joel Cadwellhttps://www.blogger.com/profile/13462586727133296404noreply@blogger.comtag:blogger.com,1999:blog-590043897961646114.post-43847647076592436322015-08-05T02:18:18.395-07:002015-08-05T02:18:18.395-07:00Hi Joel,
Ah okay, I see.
So I guess I can get th...Hi Joel,<br /><br />Ah okay, I see.<br /><br />So I guess I can get those individual-level values with:<br /><br />U <- apply(out$betadraw[1:100,1:6,],c(1,2),mean)<br /><br />Right?<br /><br />Thx so much!<br />Dirk<br /><br />Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-590043897961646114.post-23116434159021044092015-08-04T07:07:37.849-07:002015-08-04T07:07:37.849-07:00The section "Finally We Can Run the Analysis&...The section "Finally We Can Run the Analysis" is where you want to look. bayesm outputs a list and one of the elements is betadraw. I used the apply function to calculate the mean for different numbers of draws. Take a look and let me know if you have any problems.Joel Cadwellhttps://www.blogger.com/profile/13462586727133296404noreply@blogger.comtag:blogger.com,1999:blog-590043897961646114.post-81476585536018793062015-08-03T23:53:53.389-07:002015-08-03T23:53:53.389-07:00Hi Joel,
First of all let me confess that you blo...Hi Joel,<br /><br />First of all let me confess that you blog is one of the greatest ressources on the internet!<br /><br />One question regarding the article above: How can I estimate individual-level utitlity values? Or maybe I just missed that point.<br /><br />Thx for your advice.<br /><br />Regards<br />DirkAnonymousnoreply@blogger.comtag:blogger.com,1999:blog-590043897961646114.post-82732794135154698782015-06-19T13:13:34.947-07:002015-06-19T13:13:34.947-07:00One can implement covariates in RSGHB by using fix...One can implement covariates in RSGHB by using fixed parameters. For some users, it is not quite as straight-forward as it is in bayesm, but then again RSGHB can be easier to use than bayesm in other ways.<br /><br />We had a poster at the 2015 Advanced Research Techniques forum demonstrating the value of covariates and how to implement them in RSGHB, bayesm, and Sawtooth's CBC HB (a commercial software package). The poster and analysis code can be found here:<br /><br />https://github.com/jeffkeller87/ART2015_CovariatesJeff Kellerhttps://www.blogger.com/profile/02539669934433732026noreply@blogger.com