Get startedGet started for free

Fitting the model

You can use a linear regression model to estimate the avocado price elasticity. The regression formula should be:

Here, \(\beta_1\) will be the price elasticity, that is the impact of price on sales. You will assume that the elasticity is the same for regular and organic avocados. You also expect it to be negative: the higher the price, the lower the sales, that's the case for most goods. To incorporate this prior knowledge into the model, you decide to use a normal distribution with mean -80 as the prior for price. How would you build such a model?

NOTE: Recall that calling pm.sample() for the first time in a fresh Python session takes some time, as Python code is being compiled to C under the hood. To save you time, we only ask you to get the code right instead of executing it.

This exercise is part of the course

Bayesian Data Analysis in Python

View Course

Hands-on interactive exercise

Turn theory into action with one of our interactive exercises

Start Exercise