# How to access point estimates of parameters

**URL:** <https://discourse.edwardlib.org/t/how-to-access-point-estimates-of-parameters/53>\
**Category:** General\
**Created:** [March 22, 2017, 1:45am UTC](https://discourse.edwardlib.org/t/how-to-access-point-estimates-of-parameters/53 "2017-03-22T01:45:57Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![willtownes](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.edwardlib.org/willtownes/32/21_2.png) [@willtownes](https://discourse.edwardlib.org/u/willtownes)\
**Post date:** [March 22, 2017, 1:45am UTC](https://discourse.edwardlib.org/t/how-to-access-point-estimates-of-parameters/53/1 "2017-03-22T01:45:57Z")

</div>

Reading through the [linear mixed effects tutorial](http://edwardlib.org/tutorials/linear-mixed-effects-models), it seems that there is no way to access the values of the fixed effects since they are not endowed with priors like the random effects. Is this correct? If not, can someone explain how to obtain the point estimates of these parameters?

---

<div class="post-metadata">

**Author:** ![dustin](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.edwardlib.org/dustin/32/134_2.png) [@dustin](https://discourse.edwardlib.org/u/dustin)\
**Post date:** [March 22, 2017, 4:54am UTC](https://discourse.edwardlib.org/t/how-to-access-point-estimates-of-parameters/53/2 "2017-03-22T04:54:32Z")

</div>

You can access their values in the same way you would access random variables. For example, in the tutorial we wrote a model parameter,

```python
mu = tf.Variable(tf.random_normal([]))

```

After inference, simply run

```python
sess = ed.get_session()
sess.run(mu)

```

This fetches `mu` from the graph and returns a NumPy array (the point estimate). Tensors and Variables are deterministic, so fetching always returns the same value (recall for RandomVariables, fetching returns a sample from the distribution).

---

<div class="post-metadata">

**Author:** ![willtownes](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.edwardlib.org/willtownes/32/21_2.png) [@willtownes](https://discourse.edwardlib.org/u/willtownes)\
**Post date:** [March 23, 2017, 7:32pm UTC](https://discourse.edwardlib.org/t/how-to-access-point-estimates-of-parameters/53/3 "2017-03-23T19:32:12Z")

</div>

Thanks for your reply!

My underlying question is, can I use this tool to do pure maximum likelihood?

I can get it to work sometimes but not always. I came up with a simpler example of just finding the mean and sd of a univariate gaussian. Here is the code:

```auto
mu_true = 5
sd_true = 2
N = 100
xtrain = np.random.normal(mu_true,sd_true,size=N)
#edward model
s = tf.Variable(1.0)
m = tf.Variable(0.0)
x = Normal(mu=m*tf.ones(N),sigma=s*tf.ones(N))
mle = ed.Inference({},{x:xtrain})
mle.run()
sess = ed.get_session()
sess.run(m)

```

expected result: $m\approx 5$. Observed result: $m=0.0$.

If I put a prior on m and do MAP I can get the result out from the qm approximating PointMass distribution with no issue. Also interestingly, if I put a prior on m, I can get the correct point estimate for “s” using sess.run(s) as expected, but if I don’t put a prior on m, I get the initialized (incorrect) point estimate.

---

<div class="post-metadata">

**Author:** ![dustin](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.edwardlib.org/dustin/32/134_2.png) [@dustin](https://discourse.edwardlib.org/u/dustin)\
**Post date:** [March 23, 2017, 7:46pm UTC](https://discourse.edwardlib.org/t/how-to-access-point-estimates-of-parameters/53/4 "2017-03-23T19:46:32Z")

</div>

`ed.Inference` is an abstract class. Since it runs nothing, fetching `m` returns its initialized value of 0.0.

You want `ed.MAP({}, data={x: x_train})`. This will give you MLE, because you’re defining model parameters rather than placing prior distributions over them.

---

<div class="post-metadata">

**Author:** ![willtownes](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.edwardlib.org/willtownes/32/21_2.png) [@willtownes](https://discourse.edwardlib.org/u/willtownes)\
**Post date:** [March 23, 2017, 8:22pm UTC](https://discourse.edwardlib.org/t/how-to-access-point-estimates-of-parameters/53/5 "2017-03-23T20:22:00Z")

</div>

got it! Thanks again for the help.
