Let's say I have two variables, $x_1$ and $x_2$, which represent the temperatures in room A and room B, respectively. Then I have $y_1$ and $y_2$ that represent a participant's rating of how comfortable room A and room B are.

Let's say I want to find the optimal comfort level, such that the $\operatorname{mean}(x_1) < \operatorname{mean}(x_2)$.

I could run two linear regressions and get a set of equations which I could optimize based on that constraint. Or I could do a single regression, with all variables involved, and then predict over a range of temperatures, finding a set of 'optimums' that meet the constraint.

However, I've gained some interest in Bayesian optimization, and was curious if this would lend itself well to a problem like this. I'm having trouble setting up the optimization problem (thinking primarily in terms of using a package like PyMC3 to solve it).

How does one approach a problem like this from a Bayesian perspective?

  • 2
    $\begingroup$ Probably the best review and introduction to Bayesian modeling is in Gelman and Hill's book Data Analysis Using Regression and Multilevel/ Hierarchical Models. Not only is it an excellent discussion but they also include many applied examples. There is pretty good freeware for this type of model available from the Stan software website ... mc-stan.org $\endgroup$
    – user78229
    Mar 17, 2017 at 18:12

1 Answer 1


The issue is what sort of model structure to use (not whether a Bayesian approach could work -- a Bayesian approach works well for estimating parameters in virtually any kind of regression application). So, what sort of model?

The predicted values are "ratings" so I assume they are ordinal (not metric / interval scaled). The predictor values are nominal (for room) and metric/interval (for room temperature). So an ordered probit model is a good off-the-shelf approach.

Chapter 23 of DBDA2E gives examples of implementing these models in R and JAGS. Here, for example, is Figure 23.6 from DBDA2E illustrating an ordered probit model for a single metric/interval predictor: Figure 23.6 from Kruschke, DBDA2E

Here, from p. 683 of DBDA2E, is the JAGS model specification for the case when the predictor is nominal, with two levels: enter image description here

If the participants give ratings for both rooms then you have to think about a within-subjects design model...

  • $\begingroup$ Thanks for this! I'm unsure how, in such a regression, I would implement a condition where the mean of one parameter must be less than the other. $\endgroup$ Mar 20, 2017 at 12:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.