# Only inferencing partial latent variables

**URL:** <https://discourse.edwardlib.org/t/only-inferencing-partial-latent-variables/934>\
**Category:** General\
**Created:** [September 12, 2018, 2:11am UTC](https://discourse.edwardlib.org/t/only-inferencing-partial-latent-variables/934 "2018-09-12T02:11:10Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![blankV](https://avatars.discourse-cdn.com/v4/letter/b/da6949/32.png) [@blankV](https://discourse.edwardlib.org/u/blankV)\
**Post date:** [September 12, 2018, 2:11am UTC](https://discourse.edwardlib.org/t/only-inferencing-partial-latent-variables/934/1 "2018-09-12T02:11:10Z")

</div>

Hi all gamers,

I’m wondering that when doing inference with edward, do we have to feed all variables in the graphical model into the inference instance?

For example with linear regression, y = a\*x+b, the common inference would be:  
ed.KLqp({a:qa, b:qb},data={x:x\_data, y:y\_data})  
and we’ll get the approximated posterior for parameters a and b. But what if we only care about a? could we just define some prior over latent variable b and NOT feed it into the inference so it looks like this  
ed.KLqp({a:qa},data={x:x\_data, y:y\_data})

So to conclude my question is would the above inferences give me similar/same qa for approximating posterior of parameter a?

Thanks !

---

<div class="post-metadata">

**Author:** ![Focus](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.edwardlib.org/focus/32/357_2.png) [@Focus](https://discourse.edwardlib.org/u/Focus)\
**Post date:** [September 12, 2018, 9:53pm UTC](https://discourse.edwardlib.org/t/only-inferencing-partial-latent-variables/934/2 "2018-09-12T21:53:48Z")

</div>

If you only care about the posterior for p(a | X, y) then `ed.KLqp({a:qa},data={x:x_data, y:y_data})` will do that. I think should be similar (but not necessarily the same as because of the variational inference) `ed.KLqp({a:qa, b:qb},data={x:x_data, y:y_data})` if your priors are independent. The problem you will have running the first one is that you can’t make any predictions since you only have the posterior for one of the variables.

---

<div class="post-metadata">

**Author:** ![blankV](https://avatars.discourse-cdn.com/v4/letter/b/da6949/32.png) [@blankV](https://discourse.edwardlib.org/u/blankV)\
**Post date:** [October 30, 2018, 5:54pm UTC](https://discourse.edwardlib.org/t/only-inferencing-partial-latent-variables/934/3 "2018-10-30T17:54:18Z")

</div>

Hey, thanks for the reply! Yeah I understand what you mean, and the vars that are not in the inference would be integrate out with the prior so the output should be different.
