Hi Gabriel,
first of all, let me thank you for your work, it is of great help! I am learning python, pymc3, and bayesian statistics all at once, so having your code is of great help.
I think I figured out why the simple linear regression of Exercise 2 in Week 2 does not work in your notebook, when working with log(weights) to predict (while it works in the results for R).
It seems that when taking the log of weights, you should also transform the prior for beta, in the linear regression of model_2:
mu = alpha + beta * log_weight
so that beta's prior now should be:
beta = pm.Lognormal('beta', mu=0, sd=1)
instead of the previos prior of model_1:
beta = pm.Normal('beta', mu=0, sd=1)
used when working with weights as a predictor.
When using the lognormal prior, the linear model works similarly to the results obtained with the R code. It seems that the normal prior for beta is a bad one, preventing the model from proper fitting.
Hope it helps!
Sebastian.
Hi Gabriel, first of all, let me thank you for your work, it is of great help! I am learning python, pymc3, and bayesian statistics all at once, so having your code is of great help.
I think I figured out why the simple linear regression of Exercise 2 in Week 2 does not work in your notebook, when working with log(weights) to predict (while it works in the results for R). It seems that when taking the log of weights, you should also transform the prior for beta, in the linear regression of model_2:
mu = alpha + beta * log_weight
so that beta's prior now should be:
beta = pm.Lognormal('beta', mu=0, sd=1)
instead of the previos prior of model_1:
beta = pm.Normal('beta', mu=0, sd=1)
used when working with weights as a predictor.When using the lognormal prior, the linear model works similarly to the results obtained with the R code. It seems that the normal prior for beta is a bad one, preventing the model from proper fitting. Hope it helps! Sebastian.