Example notebook for truncated regression

Made a notebook to demonstrate truncated regression in PyMC3 https://github.com/drbenvincent/pymc3-demo-code/blob/master/truncated_regression_pymc3.ipynb

Very open to corrections/pull requests.

5 Likes

Wow @drbenvincent! This is a very clean notebook. One of the few that can be understood without comments. Great work!

1 Like

This is indeed very clear. Thanks for sharing.

1 Like

This is really nice and I can see what happened intuitively. Can anyone provide an explanation of why truncating the likelihood leads to a better model? If there are no data points outside the truncation bounds, then shouldn’t the log-likelihood of the existing points be the same whether it’s truncated or not?

1 Like

Using a normal likelihood function on truncated data would lead to bias in the estimate of mu. So by using a truncated normal, you are expressing your knowledge that the chance of observing data outside of the bounds is zero, which allows the estimate for mu to “expect” the cutoff and so the mu estimate won’t be biased. Does that make sense?

Based on this Help with Censored Regression I think that this example is wrong. It uses TruncatedNormal which it seems is inappropriate for truncated data :scream:.

Looks like using Bounds is appropriate in the context of truncated data… Seeking advice here Truncated observed data?

Yes! thankyou.