# Prior predicitive for linear regression

**URL:** https://discourse.pymc.io/t/prior-predicitive-for-linear-regression/3304
**Category:** Questions
**Created:** [May 21, 2019, 6:50am UTC](https://discourse.pymc.io/t/prior-predicitive-for-linear-regression/3304 "2019-05-21T06:50:54Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![Rahul\_Deora](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.pymc.io/rahul_deora/32/1866_2.png) [@Rahul\_Deora](https://discourse.pymc.io/u/Rahul_Deora)
#### Post date: [May 21, 2019, 6:50am UTC](https://discourse.pymc.io/t/prior-predicitive-for-linear-regression/3304/1 "2019-05-21T06:50:54Z")

</div>

I am unable to get the prior predictive distribution. Here is the reproducible code:

```
df = pd.read_csv('https://raw.githubusercontent.com/aloctavodia/Statistical-Rethinking-with-Python-and-PyMC3/master/Data/Howell1.csv',sep=';')
with pm.Model() as m4_3:
    alpha = pm.Normal('alpha', mu=178, sd=100)
    beta = pm.Normal('beta', mu=0, sd=10)
    sigma = pm.Uniform('sigma', lower=0, upper=50)
    mu = pm.Deterministic('mu', alpha + beta * (df.weight - df.weight.mean() )) # try uncomenting this line and comenting the above line
    height = pm.Normal('height', mu=mu, sd=sigma)
    trace_4_3 = pm.sample(1000, tune=1000)

```

I get

```
The error when converting the test value to that variable type:
Wrong number of dimensions: expected 0, got 1 with shape (544,). 

```

beause I have put in a input of weight in beta, but not output of height. How do I generate Prior predicitive for this model?

---

<div class="post-metadata">

### Author: ![Rahul\_Deora](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.pymc.io/rahul_deora/32/1866_2.png) [@Rahul\_Deora](https://discourse.pymc.io/u/Rahul_Deora)
#### Post date: [May 22, 2019, 7:51am UTC](https://discourse.pymc.io/t/prior-predicitive-for-linear-regression/3304/2 "2019-05-22T07:51:59Z")

</div>

Can anyone help me with this?

---

<div class="post-metadata">

### Author: ![chartl](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.pymc.io/chartl/32/1515_2.png) [@chartl](https://discourse.pymc.io/u/chartl)
#### Post date: [May 22, 2019, 3:40pm UTC](https://discourse.pymc.io/t/prior-predicitive-for-linear-regression/3304/3 "2019-05-22T15:40:22Z")

</div>

```auto
with pm.Model() as m4_3:
    alpha = pm.Normal('alpha', mu=178, sd=100)
    beta = pm.Normal('beta', mu=0, sd=10)
    sigma = pm.Uniform('sigma', lower=0, upper=50)
    mu = pm.Deterministic('mu', alpha + beta * (df.weight - df.weight.mean() )) # try uncomenting this line and comenting the above line
    height = pm.Normal('height', mu=mu, sd=sigma, testval=100.)
    trace_4_3 = pm.sample_prior_predictive(1000)
    
vn = [x for x in trace_4_3.keys() if x[-1] != '_']
for v in vn:
    if len(trace_4_3[v].shape) > 1:
        sbn.kdeplot(trace_4_3[v][:,0])
    else:
        sbn.kdeplot(trace_4_3[v])

```

![image](https://canada1.discourse-cdn.com/flex036/uploads/pymc3/original/2X/1/16b62a082dd800f98ab92e3480ec9955660b5a9a.png)
