I am given the following dataset:
x = (1,2,3,4,5,6,7,8,9,10) y = (25,17,20,26,10,19,20,9,15,10)Each $ y_x $ follows an exponential distribution with parameter $ \lambda_x $, where $ \lambda_x=b_0 + b_1x $.
Suppose that $ (b_0,b_1) $ have a uniform prior [0,1].
Question: Find the posterior density of $b_0$ and $b_1$
The likelihood function is equal to: $$L(b_0,b_1|x,y)=\prod_1^n\lambda_xe^{-\lambda_x}=\prod_1^n(b_0 + b_1x)e^{-(b_0 + b_1x)}$$
The posterior is proportional to:
$$ f(b_0,b_1) \propto {\rm prior}\times {\rm likelihood} \propto (1)\times\prod_1^n (b_0 + b_1x)e^{-(b_0 + b_1x)} \propto \prod_1^n(b_0 + b_1x)e^{-(b_0 + b_1x)} $$
Question: Generate 1,000 samples (using importance sampling), and use these samples to find the posterior mean and variance of $b_0$ and $b_1$.
I have created $n=1,000$ samples for the posterior distribution using importance sampling.
My understanding of importance sampling:
$$ E(f(b_0,b_1)) = \sum f(b_0,b_1) \times p(b_0,b_1) = \sum f(b_0,b_1) \times p(b_0,b_1) \times \frac{g(b_0,b_1)}{g(b_0,b_1)} = \sum \frac{f(b_0,b_1) \times p(b_0,b_1)}{g(b_0,b_1)} \times g(b_0,b_1) $$
Let $ \frac{p(b_0,b_1)}{g(b_0,b_1)} = w(b_0,b_1) $. Then we get:
$$ E(f(b_0,b_1)) = \frac{\sum f(b_0,b_1) \times w(b_0,b_1)}{\sum w(b_0,b_1)} $$.
How do I use these samples to get information about $b_0$ and $b_1$ (i.e., posterior mean and posterior variance)?
If I want to find the mean of $b_0$, I need to find:
$$ E(b_0)=\sum\limits_{b_0} b_0 \times f(b_0 | x,y) $$ where $ f(b_0 | x,y) $ is the marginal posterior of $b_0$. I am stuck at this point... how do I find $ f(b_0 | x,y) $ for my dataset? Do I just need to compute the following quantity?
$$ E(b_0)=\sum\limits_{b_0} b_0 \times f(b_0,b_1| x,y) $$
[self-study]tag & read its wiki. Then tell us what you understand thus far, what you've tried & where you're stuck. We'll provide hints to help you get unstuck. – gung - Reinstate Monica Dec 13 '16 at 01:13