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.
Cet exercice fait partie du cours
Bayesian Data Analysis in Python
Exercice interactif pratique
Passez de la théorie à la pratique avec l’un de nos exercices interactifs
